• Resolved mattapex

    (@mattapex)


    So the new WP Job Manager update 1.36.x adds Salary as an option… but I imagine like many others, I’ve previously used functions.php to add this functionality.

    It means there are hundreds of jobs in the system that have salaries listed via functions.php so updating to the new version of WP Job Manager creates a new salary field that’s empty.

    Is there a way (other than manually copying) of getting this salary field information from the previously functions.php created salary field into the new one available via the plugin update?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter mattapex

    (@mattapex)

    This is the code that was used previously:

    // add salary field to WP Job Manager
    add_filter( 'submit_job_form_fields', 'frontend_add_salary_field' );
    
    function frontend_add_salary_field( $fields ) {
      $fields['job']['job_salary'] = array(
        'label'       => __( 'Salary or rate info', 'job_manager' ),
        'type'        => 'text',
        'required'    => true,
        'placeholder' => 'e.g. £40,000 or Competitive salary + benefits',
        'priority'    => 7
      );
      return $fields;
    }
    
    // add salary field to admin dashboard
    add_filter( 'job_manager_job_listing_data_fields', 'admin_add_salary_field' );
    function admin_add_salary_field( $fields ) {
      $fields['_job_salary'] = array(
        'label'       => __( 'Salary or rate info', 'job_manager' ),
        'type'        => 'text',
        'placeholder' => 'e.g. e.g. £40,000 or Competitive salary + benefits',
        'description' => ''
      );
      return $fields;
    }
    
    // display salary field on front end
    add_action( 'single_job_listing_meta_end', 'display_job_salary_data' );
    function display_job_salary_data() {
      global $post;
    
      $salary = get_post_meta( $post->ID, '_job_salary', true );
    
      if ( $salary ) {
        echo '<li style="color:white;">' . __( 'Salary:' ) . ' ' . esc_html( $salary ) . '</li>';
      }
    }
    Thread Starter mattapex

    (@mattapex)

    Downgrading and re-updating the plugin, then removing the custom code from my child theme’s functions.php file seems to have resolved the issue. Now we just need to sort out the USD/YEAR default text issue!

    This means it should be perfectly fine then you shouldn’t have to make any changes at all, and even your custom code should be left so that it customizes that field to use the wording you want.

    The only thing you may need to remove is the code to output the salary on the frontend.

    Plugin Support Jay

    (@bluejay77)

    Hi @mattapex,

    Thank you for the report. We have added this issue on our issue tracker here:

    https://github.com/Automattic/WP-Job-Manager/issues/2278

    We don’t have an ETA when the fix will be released, I’m afraid. In the meantime, you can use this code snippet as a workaround:

    add_filter( 'wpjm_job_salary_currency', function( $currency ) {
      return 'GBP';
    } );

    You can replace GBP with the currency of your choice.

    I hope that helps! Let us know if you have any other questions.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘New update adds salary field, but how to get data from old salary field?’ is closed to new replies.