How to split out Job and Company details into separate pages.
-
The WP Job Manager plugin appears to be a really well put together.
I am trying to do something which I thought should be quite straight forward but I’ve come up against a wall. Hoping I may be able to get some help here?
Essentially I want each employer to set their company name, tagline and logo etc. on a separate page within their dashboard. Then when they post a job the same company info is applied to all their job postings, so they’ll only be able to post jobs for their own company as stored in their user meta.
So I have been following the documentation and used the shortcode
[submit_job_form]
on both the “Post a job” (ID: 83) and “Update company details” (ID: 164) pages. Now I have been adding hooks to the functions.php file:// separate out company and job fields to different pages. add_filter( 'submit_job_form_fields', 'frontend_job_form_customise' ); function frontend_job_form_customise( $fields ) { if( is_page(83) ){ // members/job-dashboard/post-a-job/ unset($fields['company']); // take out company fields. managed separately in profile. } if( is_page(164) ){ //members/update-profile/company-details/ unset($fields['job']); // take out job fields. this is for updating user meta. } return $fields; } add_action( 'submit_job_form_job_fields_end', 'invisible_company_fields' ); function invisible_company_fields(){ if( is_page(83) ){ // still need to store company meta in job submit form using hidden fields $hiddenfields = array('company_name','company_website' ,'company_tagline' ,'company_video' ,'company_twitter','company_logo'); $str = ''; foreach($hiddenfields as $field){ // get meta value if exist $val = get_user_meta( get_current_user_id(), '_'.$field, true); if($val !== ''){ $str .= '<input type="hidden" name="'.$field.'" value="'.$val.'">'; } } echo $str; } } /** * Remove the preview step for company details form only. * @param array $steps * @return array */ function custom_submit_job_steps( $steps ) { if( is_page(164) ){ unset( $steps['preview'] ); } return $steps; } add_filter( 'submit_job_steps', 'custom_submit_job_steps' ); /** * Change button text */ function change_preview_text() { if( is_page(164) ){ return __( 'Update details', 'rf' ); }else{ return __( 'Preview', 'rf' ); } } add_filter( 'submit_job_form_submit_button_text', 'change_preview_text' );
Now while the fields are being removed from the forms where desired, all sorts of problems are arising. When I save a company, it still displays the Preview page and an error is thrown: “Notice: Undefined index: job in wp-content/plugins/wp-job-manager/includes/forms/class-wp-job-manager-form-submit-job.php on line 434” and then when I add a job, the first time the company data is stored but the second time it has been cleared.
I have tried quite a few things, such as setting my own
$steps['submit']['handler']
in thesubmit_job_steps
filter but cannot get it to work! Any help or tips appreciated.Thanks!
- The topic ‘How to split out Job and Company details into separate pages.’ is closed to new replies.