If you're using the WP Job Manager plugin for your job or any kind of listing site and looking for adding some custom fields on the front-end of the job submission page which is created using the [submit_job_form] default shortcode by WPJM then this post could be helpful for you.
In this post, I am going to share with you a few custom-written PHP codes to add a custom text field to the job submission page of WP Job Manager.
You can add those codes within your functions.php file using your theme editor or you can use a plugin like Code Snippets, Scripts Organizer, or Advanced Scripts if you don't want to mess with the backend codes of the funtions.php file.
Add A Custom Text Field
To add a custom text field on the job submission page you would need to add this code to your website and in this section, I'll teach you how to customize the custom text field as per your requirement.
add_filter( 'submit_job_form_fields', 'frontend_add_Custom_Text_field' ); function frontend_add_Custom_Text_field( $fields ) { $fields['company']['Custom_Text'] = array( 'label' => __( 'Custom Text (Optional)', 'job_manager' ), 'type' => 'text', 'required' => false, 'placeholder' => 'e.g. Add anything You Want', 'priority' => 1, ); return $fields; }
Step 1:
See carefully the very first line of the code where I have highlighted the text "Custom_Text" you just need to replace that thing with your own text, for example; add_filter( 'submit_job_form_fields', 'frontend_add_Date_of_Birth_field' );
Step 2:
Then you also need to replace the text from the second line of the code. As for example; function frontend_add_Date_of_Birth_field( $fields ) {
Step 3:
Then you need to change the same text on the third line of the code. As for example; $fields['company'][' Date_of_Birth '] = array(
One thing to keep in mind, if you add the field on the job application section then you just need to replace the company word from the job word in this line that's it. For example;
$fields[' job '][' Date_of_Birth '] = array(
Step 4:
Then on the fourth line also you need to replace the text from your own text as it's a label and will be visible on the front page thus you also should mention if the field is Required or Optional within the bracket.
As for example; 'label' => __( 'Date of Birth (Optional)', 'job_manager' ),
Step 5:
Then the next thing is to leave the 5th line of the code as it is because we are creating a custom text field thus it would be as text.
As for example; 'type' => 'text',
Step 6:
The 6th line should be left as it is if you want to keep this field optional but if you want to make this field required then you need to replace the word false with true.
As for example; 'required' => true,
Step 7:
The 7th line of the code is for a placeholder so you can add whatever you want to add on the placeholder, like in this placeholder you can indicate the format of date of birth.
As for example; 'placeholder' => 'e.g. 01.01.1990',
Step 8:
Then in the 8th line of the code select the priority or the position of the field on the page, like as you want to keep it on the top or in the below that you can decide in this line.
Here you just need to replace the number with your own number, suppose you want to keep this field below after 9 other fields then you have to replace the 1 with 10 on this line of code.
As for example; 'priority' => 10,
Conclusion
Nothing more you have to do once you have followed and made exact changes as I taught in this article.
Leave the rest of the code as it is and don't change any single thing from this code otherwise, nothing will work.
Once you have made the changes now you are ready to go, just add the code within your website using the functions.php or Code Snippets plugin and your custom text field is ready and live.
I hope I have been able to solve your problem regarding adding a custom text field on the job submission page of the WP job manager plugin.
If you face any difficulties to use this code then feel free to share your feedback in the comment box below or if you want me to add the custom fields for you then you can hire me for this job.
Thank you for visiting Toolonomy.com!