Filter uncanny-automator

automator_wp_job_manager_application_fields_defaults

Filters the default application form fields for WP Job Manager submissions.

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

Description

Filters the default job application fields for WP Job Manager. Developers can modify this array to add, remove, or change the available fields for job applications before they are processed by the plugin. This hook fires when retrieving default fields.


Usage

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

Return Value

The filtered value.


Examples

/**
 * Example of modifying the default WP Job Manager application form fields.
 *
 * This filter allows you to add, remove, or modify the default fields
 * that are recognized by the Automator plugin for WP Job Manager applications.
 *
 * @param array $default_fields An array of default field slugs.
 * @return array The modified array of default field slugs.
 */
add_filter( 'automator_wp_job_manager_application_fields_defaults', function( $default_fields ) {

    // Let's say we want to remove the 'message' field from the defaults
    // and add a custom field slug, for example, 'company-website'.
    $new_defaults = array_diff( $default_fields, array( 'message' ) );

    // Add a custom field slug if it's not already present.
    if ( ! in_array( 'company-website', $new_defaults ) ) {
        $new_defaults[] = 'company-website';
    }

    // You could also reorder them if needed, but that's more complex.
    // For this example, we'll just return the modified array.
    return $new_defaults;

}, 10, 1 ); // Priority 10, 1 accepted argument

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:578

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