• Resolved dievernon

    (@dievernon)


    Greetings –

    I tried search, but wasn’t able to find what I’m looking to accomplish, so my hope is someone can help or point me in the right direction. I have 2 things I want to do:

    1 – I want to make the Company Name field on the job submit form be optional. I tried the following:

    add_filter( ‘job_manager_job_listing_data_fields’, ‘custom_job_manager_job_listing_data_fields’ );

    function custom_job_manager_job_listing_data_fields( $fields ) {

    $fields[‘company_name’][‘required’] = “false”;

    return $fields;
    }

    in functions.php – but it still pops the alert telling me to fill out the field. I’m sure there’s something wrong with my code, but I can’t find it.

    2 – What I’d also like to set up is, if someone leaves that field blank – then, on the find a job page, where it normally has the company name under the job title – I’d like it to say “Company Name Withheld”

    I’m relatively new to these kinds of edits, so I’m unsure of the process of setting that up. Any and all assistance that is offered would be greatly appreciated. Thank you for reading!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor jonryan

    (@jonryan)

    @dievernon for 1) I think you are missing the [‘job’] as the first array element.

    2) what you want to do here is actually pretty simple and can be one of two ways. You can edit the file here where it checks the string length: https://github.com/Automattic/WP-Job-Manager/blob/d1341dd2900c81ad8de0bf67bbc6afef126ea28f/wp-job-manager-template.php#L571

    The better way is to use a filter, and you can use the_company_name. You’d essentially want to make a filter that does the above, checking the string length and if it’s zero returning “company name withheld”.

    good luck!

    Thread Starter dievernon

    (@dievernon)

    Hi Jon – thanks for the reply!

    1 – I inserted [‘job’] as you said:

    add_filter( ‘job_manager_job_listing_data_fields’, ‘custom_job_manager_job_listing_data_fields’ );
    function custom_job_manager_job_listing_data_fields( $fields ){
    $fields[‘job’][‘company_name’][‘required’] = “false”;
    return $fields;
    }

    But I’m still getting the same pop tooltip with yellow ! box that says please fill out this field.

    2 – Thank you for the insight on this. I will look into how to implement this!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Make Company Name Field optional’ is closed to new replies.