WP Job Manager Plugin Custom Filters & Functions

I’ve been learning the in’s and out’s of Automattic’s WP Job Manager plugin these past couple of weeks. It’s a powerful job board pluginĀ for WordPress, but the real awesomeness is how it can be customized. Most of the below are custom filters and functions (some are written by me, some found otherwhere that I’ve used), I thought they’d be helpful to have them all in one place.

Add a custom TEXT form field

To the “Post a job” form:

 
// Add SALARY
 
add_filter( 'submit_job_form_fields', 'frontend_add_salary_field' );
 
function frontend_add_salary_field( $fields ) {
  $fields['job']['job_salary'] = array(
    'label'       => __( 'Salary ($)', 'job_manager' ),
    'type'        => 'text',
    'required'    => true,
    'placeholder' => '',
    'priority'    => 4.3
  );
  return $fields;
}

To the admin area:

 
add_filter( 'job_manager_job_listing_data_fields', 'admin_add_salary_field' );
 
function admin_add_salary_field( $fields ) {
  $fields['_job_salary'] = array(
    'label'       => __( 'Salary ($)', 'job_manager' ),
    'type'        => 'text',
    'placeholder' => '',
    'description' => ''
  );
  return $fields;
}

Add a custom dropdown form field

To the “Post a job” form:

 
// Add EXPERIENCE custom field
 
add_filter( 'submit_job_form_fields', 'frontend_add_experience_field' );
 
function frontend_add_experience_field( $fields ) {
  $fields['job']['job_exp'] = array(
    'label'       => __( 'Experience Level', 'job_manager' ),
    'type'        => 'select',
    'options' => array('Select experience level', '1+ years' => '1+ years', '2+ years' => '2+ years', '3+ years' => '3+ years', '4+ years' => '4+ years', '5+ years' => '5+ years'),
    'required'    => true,
    'placeholder' => '',
    'priority'    => 4.2
  );
  return $fields;
}

To the admin area:

 
add_filter( 'job_manager_job_listing_data_fields', 'admin_add_experience_field' );
 
function admin_add_experience_field( $fields ) {
  $fields['_job_exp'] = array(
    'label'       => __( 'Experience Level', 'job_manager' ),
    'type'        => 'select',
    'options' => array('Select experience level', '1+ years' => '1+ years', '2+ years' => '2+ years', '3+ years' => '3+ years', '4+ years' => '4+ years', '5+ years' => '5+ years'),
    'placeholder' => '',
    'description' => ''
  );
  return $fields;
}

Add a custom WYSIWYG form field

To the “Post a job” form:

 
// Add DUTIES custom field
 
add_filter( 'submit_job_form_fields', 'frontend_add_duties_field' );
 
function frontend_add_duties_field( $fields ) {
  $fields['job']['job_duties'] = array(
    'label'       => __( 'Duties', 'job_manager' ),
    'type'        => 'wp-editor',
    'required'    => true,
    'placeholder' => '',
    'priority'    => 6.1
  );
  return $fields;
}

To the admin area (just using a plain textarea field here):

 
add_filter( 'job_manager_job_listing_data_fields', 'admin_add_duties_field' );
 
function admin_add_duties_field( $fields ) {
  $fields['_job_duties'] = array(
    'label'       => __( 'Duties', 'job_manager' ),
    'type'        => 'textarea',
    'placeholder' => '',
    'description' => ''
  );
  return $fields;
}

To display the custom WYSIWYG fields with proper formatting:

 
echo apply_filters( 'the_job_description', get_post_meta($post->ID, '_job_duties', true) );

Remove various company fields

From displaying on the single post listing:

 
add_action( 'init', 'remove_company_listing' );
 
function remove_company_listing() {
    remove_action( 'single_job_listing_start', 'job_listing_company_display', 30, 0 );
}

From displaying on the “Post Job” form:

 
add_filter( 'submit_job_form_fields', 'remove_company_fields_form' );
 
function remove_company_fields_form( $fields ) {
    if( ! isset( $fields['company'] ) ) return $fields;
 
    if( isset( $fields['company']['phone'] ) ) unset( $fields['company']['phone']);
    if( isset( $fields['company']['company_website'] ) ) unset( $fields['company']['company_website']);
    if( isset( $fields['company']['company_video'] ) ) unset( $fields['company']['company_video']);
    if( isset( $fields['company']['company_tagline'] ) ) unset( $fields['company']['company_tagline']);
    if( isset( $fields['company']['company_twitter'] ) ) unset( $fields['company']['company_twitter']);
    if( isset( $fields['company']['company_logo'] ) ) unset( $fields['company']['company_logo']);
    if( isset( $fields['job']['application'] ) ) unset( $fields['job']['application']);
 
    return $fields;
}

From display in the admin area (when editing/adding job from admin):

 
add_filter( 'job_manager_job_listing_data_fields', 'remove_company_fields_admin' );
 
function remove_company_fields_admin( $fields ) {
 
    if( isset( $fields['_phone'] ) ) unset( $fields['_phone']);
    if( isset( $fields['_company_website'] ) ) unset( $fields['_company_website']);
    if( isset( $fields['_company_video'] ) ) unset( $fields['_company_video']);
    if( isset( $fields['_company_tagline'] ) ) unset( $fields['_company_tagline']);
    if( isset( $fields['_company_twitter'] ) ) unset( $fields['_company_twitter']);
    if( isset( $fields['_company_logo'] ) ) unset( $fields['_company_logo']);
    if( isset( $fields['_job']['_application'] ) ) unset( $fields['_job']['_application']);
 
    return $fields;
}

Remove geolocation

 
add_filter( 'job_manager_geolocation_enabled', 'smyles_disable_geolocation' );
 
function smyles_disable_geolocation( $enabled ){
    return false;
}

You’ll need to also delete the link itself from the location from the content-single-job_listing-meta.php template.

Change category form field to single select field

 
add_filter( 'submit_job_form_fields', 'change_category_job_form_fields' );
 
function change_category_job_form_fields( $fields ) {
 
    $fields['job']['job_category']['type'] = "term-select";
 
    return $fields;
}

Add custom blank option for select fields

This gets added to the term-select-field.php template.

 
// add this to the top of the file
 
if ($field['taxonomy'] == 'job_listing_type') $label = 'job type';
if ($field['taxonomy'] == 'job_listing_category') $label = 'category';
 
// Add this next bit to the wp_dropdown_categories options array
 
'show_option_none' => 'Select '.$label,

Display the “job postings left” count

This can be added anywhere in the templates to show the count left over. I used this on the Post Job pages, so the user could see they have “X job posts left in package”.

 
<?php
 
     // Find users package
     $packages = wc_paid_listings_get_user_packages(get_current_user_id(), 'job_listing');
     $packages = array_shift($packages);
 
     // delete package limit from packages used
     // to get current packages left
     $package_count = ($packages->package_limit - $packages->package_count);			
 
?>
 
<p>You have <strong><?php echo $package_count;?> job posts</strong> left in your package.</p>

I’m currently looking for a way to skip the “Choose package” step (this requires the WC Paid Listings add-on). I’ll post more as I go and feel free to tweet me if you need help with the Job Manager plugin and I’ll try to answer ASAP!