Filter Dynamic uncanny-automator

automator_wp_job_manager_application_add_field_token_{dynamic}

> **Note:** This is a dynamic hook. The actual hook name is constructed at runtime. Filters the value of a job application field token before it's added, allowing customization of token replacements.

add_filter( 'automator_wp_job_manager_application_add_field_token_{dynamic}', $callback, 10, 1 );

Description

Filters whether a specific WP Job Manager application field should be available as an automator token. Developers can return false to exclude a field, perhaps for sensitive data. This hook fires during the retrieval of available fields for tokenization.


Usage

add_filter( 'automator_wp_job_manager_application_add_field_token_{dynamic}', 'your_function_name', 10, 1 );

Parameters

$field (mixed)
This parameter is a boolean value, likely used to indicate whether to include default fields in the output.

Return Value

The filtered value.


Examples

/**
 * Modify the inclusion of a specific WP Job Manager application field token based on its type.
 * This example prevents 'date' type fields from being added as tokens.
 *
 * @param bool  $include_field Whether to include the field as a token (default: true).
 * @param array $field         The field data array.
 *
 * @return bool Modified inclusion status.
 */
add_filter(
	'automator_wp_job_manager_application_add_field_token_date', // Dynamically generated hook name for a 'date' field
	function ( $include_field, $field ) {
		// If the field type is 'date', we don't want it as a token.
		if ( isset( $field['type'] ) && 'date' === $field['type'] ) {
			return false; // Prevent this field from being added as a token.
		}

		// For all other field types, keep the default inclusion logic.
		return $include_field;
	},
	10, // Priority: standard WordPress priority.
	2  // Accepted Args: The filter passes two arguments: the initial boolean and the $field array.
);

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/integrations/wp-job-manager/tokens/wpjm-token-manager.php:593

private static function get_job_application_form_fields() {
		$fields = array();

		if ( function_exists( 'get_job_application_form_fields' ) ) {
			$all_fields = get_job_application_form_fields();
			$defaults   = apply_filters(
				'automator_wp_job_manager_application_fields_defaults',
				array(
					'full-name',
					'email-address',
					'message',
					'online-resume',
					'upload-cv',
				)
			);
			foreach ( $all_fields as $key => $field ) {
				if ( in_array( $key, $defaults, true ) || 'file' === $field['type'] ) {
					continue;
				}

				if ( apply_filters( 'automator_wp_job_manager_application_add_field_token_' . $key, true, $field ) ) {
					$fields[ $key ] = $field;
				}
			}
		}

		return $fields;
	}


Scroll to Top