• Hi. I hope you are doing well. I have added this code to enable mandatory field.

    add_filter( 'submit_job_form_fields', 'custom_submit_job_form_fields');

    function custom_submit_job_form_fields( $fields ) {


    $fields['job']['job_location']['required'] = true;
    $fields['job']['job_salary']['required'] = true;
    $fields['company']['company_logo']['required'] = true;

    return $fields;
    }

    The code is working fine but to add job_type data field. The below given code is not working. Can you guide why is it not working.

    add_filter( 'submit_job_form_fields', 'frontend_add_job_type_field', 20 );
    function frontend_add_job_type_field( $fields ) {
    $fields['job']['job_type'] = array(
    'label' => __( 'Job Type', 'wp-job-manager' ),
    'type' => 'select', // Dropdown field type
    'required' => true,
    'placeholder' => __( 'Choose job type…', 'wp-job-manager' ),
    'priority' => 6,
    'default' => 'full-time',
    'options' => array(
    'full-time' => __( 'Full Time', 'wp-job-manager' ),
    'part-time' => __( 'Part Time', 'wp-job-manager' ),
    'freelance' => __( 'Freelance', 'wp-job-manager' ),
    ),
    );
    return $fields;
    }

    I have tried different codes and also used the one given below but it is not working. Maybe I am using the wrong hook name like frontend_add_job_type_field. Kindly help. Thanks

    'label'       => __( 'Job type', 'wp-job-manager' ),
    'type' => $job_type,
    'required' => true,
    'placeholder' => __( 'Choose job type…', 'wp-job-manager' ),
    'priority' => 4,
    'default' => 'full-time',
    'taxonomy' => \WP_Job_Manager_Post_Types::TAX_LISTING_TYPE,
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Cara

    (@dcka)

    Hi, @mj00712! It looks like you want to have a job type field in your job submission form. If so, you don’t need to add custom code for that. “Job Type” should already be available in the job submission form by default.

    If I misunderstood your goal, please feel free to share more details.

    Thread Starter Muhammad Junaid

    (@mj00712)

    By Job Type I mean Employment Type, Full-Time, Part-Time etc. I have used this code and it shows on the frontend. Is it correct way to do it?

    // Add custom field to the job submission form
    add_filter( 'submit_job_form_fields', 'add_custom_job_type_field' );
    function add_custom_job_type_field( $fields ) {
    // Use a unique key (here, 'custom_job_type') to avoid conflict with WP Job Manager’s built-in taxonomies.
    $fields['job']['custom_job_type'] = array(
    'label' => __( 'Job Type', 'wp-job-manager' ),
    'type' => 'select', // Dropdown field
    'required' => true,
    'placeholder' => __( 'Select job type...', 'wp-job-manager' ),
    'priority' => 6.1,
    'default' => 'full-time',
    'options' => array(
    'full-time' => __( 'Full Time', 'wp-job-manager' ),
    'part-time' => __( 'Part Time', 'wp-job-manager' ),
    'freelance' => __( 'Freelance', 'wp-job-manager' ),
    ),
    );
    return $fields;
    }

    // Save the custom field value when a job is submitted/updated
    add_action( 'job_manager_update_job_data', 'save_custom_job_type_field', 10, 2 );
    function save_custom_job_type_field( $job_id, $values ) {
    if ( isset( $values['job']['custom_job_type'] ) ) {
    update_post_meta( $job_id, '_custom_job_type', sanitize_text_field( $values['job']['custom_job_type'] ) );
    }
    }

    Also, can you check if adding job type in structured data is correct?

    // Add Google structured data for Job Type

    add_filter( 'wpjm_get_job_listing_structured_data', 'add_job_type_structured_data' );

    function add_job_type_structured_data( $data ) {
    global $post;

    // Retrieve the custom job type from the post meta
    $job_type = get_post_meta( $post->ID, '_custom_job_type', true );

    if ( ! empty( $job_type ) ) {
    // Schema.org's JobPosting uses the "employmentType" property for this value.
    $data['employmentType'] = $job_type;
    }

    return $data;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.