Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Mike Jolley

    (@mikejolley)

    Hi Steve

    Focussing on the frontend part, maybe a line was missed. If I place this code:

    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' => 7
      );
      return $fields;
    }

    I instantly get the new field:

    https://dl.dropboxusercontent.com/s/6ulgy576u1uxbdm/2015-01-13%20at%2018.20%202x.png?dl=0

    Did you by any chance miss the add_filter line? If you post your ensure functions.php file online we can check if you still have the changes. You can paste it to https://gist.github.com/ if you want.

    Hi Steve i get the same issue. I followed the instructions to the letter. I get the admin fields. Perfect! However they just wont display on the actual front end.

    Any assistance would be great.

    Here is the code i entered:

    add_filter( 'job_manager_job_listing_data_fields', 'admin_add_job_code_field' );
    function admin_add_job_code_field( $fields ) {
      $fields['_job_code'] = array(
        'label' => __( 'Code', 'job_manager' ),
        'type' => 'text',
        'placeholder' => '',
        'description' => ''
      );
      return $fields;
    }
    add_action( 'single_job_listing_meta_end', 'display_job_code_data' );
    function display_job_code_data() {
      global $post;
    
      $salary = get_post_meta( $post->ID, '_job_code', true );
    
      if ( $code ) {
        echo '<li>' . __( 'code:' ) . ' ' . $job_code . '</li>';
      }
    }
    add_filter( 'submit_job_form_fields', 'frontend_add_job_code_field' );
    function frontend_add_job_code_field( $fields ) {
      $fields['job']['job_code'] = array(
        'label' => __( 'Code', 'job_manager' ),
        'type' => 'text',
        'required' => true,
        'placeholder' => '',
        'priority' => 6
      );
      return $fields;
    }
    add_action( 'job_manager_update_job_data', 'frontend_add_job_code_field_save', 10, 2 );
    function frontend_add_job_code_field_save( $job_id, $values ) {
      update_post_meta( $job_id, '_job_code', $values['job']['job_code'] );
    }

    Plugin Author Mike Jolley

    (@mikejolley)

    @ioto It’s not clear if you’re referring to the form on the frontend, or the job on the frontend?

    In this instance the job on the front end. I can see the fields in the admin. Hope that helps.

    Plugin Author Mike Jolley

    (@mikejolley)

    Thats because you have

    $salary = get_post_meta( $post->ID, '_job_code', true );

    instead of

    $code = get_post_meta( $post->ID, '_job_code', true );

    doh!

    Will update.

    Thanks Mike for the correction ?? All is now great again.

    Is there an easy way of getting this custom field also displayed on the job listings area before location field?

    Plugin Author Mike Jolley

    (@mikejolley)

    @ioto Probably override/edit the template files for that. There is a guide to template overrides in the docs.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘want to add fields’ is closed to new replies.