Filter uncanny-automator

automator_options_show_id

Filters whether the Automator option to show the ID is enabled, firing when displaying core Automator options.

add_filter( 'automator_options_show_id', $callback, 10, 1 );

Description

Filters whether the ID field should be displayed for certain automator options. Developers can return `false` to hide the ID field, useful for scenarios where the ID is not relevant or should be managed internally. This filter runs when generating automator option fields.


Usage

add_filter( 'automator_options_show_id', 'your_function_name', 10, 1 );

Parameters

$this (mixed)
This parameter determines whether the ID of the option should be displayed.

Return Value

The filtered value.


Examples

add_filter(
	'automator_options_show_id',
	function ( $show_id, $field_data ) {
		// This filter allows you to conditionally hide or show the ID for options
		// in the Automator plugin. We'll demonstrate hiding it if the input type
		// is 'select' and the option code is 'user_role'.

		// Check if the option is for user roles and if it's a select input.
		if ( isset( $field_data['input_type'] ) && 'select' === $field_data['input_type'] &&
			 isset( $field_data['option_code'] ) && 'user_role' === $field_data['option_code'] ) {
			// Hide the ID for user role select options.
			return false;
		}

		// Otherwise, return the original value.
		return $show_id;
	},
	10, // Priority
	2   // Accepted arguments count
);

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/core/lib/helpers/class-automator-recipe-helpers-field.php:432
src/core/lib/helpers/class-automator-recipe-helpers-field.php:524
src/core/lib/helpers/class-automator-recipe-helpers-field.php:603
src/integrations/armember/helpers/armember-helpers.php:80

public function select( $args = array() ) {

		$defaults                 = array(
			'option_code'              => 'SELECT',
			'label'                    => esc_attr__( 'Option', 'uncanny-automator' ),
			'input_type'               => 'select',
			'supports_tokens'          => apply_filters( 'automator_option_select_field', false ),
			'required'                 => true,
			'default_value'            => null,
			'options'                  => array(),
			'custom_value_description' => '',
			'supports_custom_value'    => apply_filters( 'automator_supports_custom_value', true, $args ),
			'relevant_tokens'          => null,
			'is_ajax'                  => false,
			'chained_to'               => null,
			'endpoint'                 => null,
			'token_name'               => '',
			'options_show_id'          => apply_filters( 'automator_options_show_id', true, $this ),
			'exclude_default_token'    => false,
		);
		$args                     = wp_parse_args( $args, $defaults );
		$option_code              = $args['option_code'];
		$input_type               = $args['input_type'];
		$label                    = $args['label'];
		$required                 = $args['required'];
		$default                  = $args['default_value'];
		$options                  = $args['options'];
		$custom_value_description = $args['custom_value_description'];
		$supports_custom_value    = $args['supports_custom_value'];
		$supports_tokens          = $args['supports_tokens'];
		$relevant_tokens          = $args['relevant_tokens'];
		$token_name               = $args['token_name'];
		$options_show_id          = $args['options_show_id'];
		$exclude_default_token    = $args['exclude_default_token'];

		$option = array(
			'option_code'              => $option_code,
			'label'                    => $label,
			'input_type'               => $input_type,
			'supports_tokens'          => $supports_tokens,
			'required'                 => $required,
			'default_value'            => $default,
			'options'                  => $options,
			'custom_value_description' => $custom_value_description,
			'supports_custom_value'    => $supports_custom_value,
			'relevant_tokens'          => $relevant_tokens,
			'token_name'               => $token_name,
			'options_show_id'          => $options_show_id,
			'exclude_default_token'    => $exclude_default_token,
		);

		// TODO:: add keys optionally
		//      'is_ajax'                  => false,
		//          'chained_to'               => null,
		//          'endpoint'                 => null,

		return apply_filters( 'automator_option_select_field', $option );
	}


Scroll to Top