I don’t think you are on the latest release – I know that unsetting company should cause no notices as I’ve used it a few times.
Are you using 1.13?
Hi
Thanks for looking into it. I’m definitely using 1.13. They are only warnings I believe so you won’t get any errors without WP Debug turned on. They are being reported by the WP Error Fix plugin when a job is submitted.
WP Error Fix is reporting the following. The number in brackets is the line number.
Undefined index: application
/wp-content/plugins/wp-job-manager/includes/forms/class-wp-job-manager-form-submit-job.php(567) 2014-07-30 17:28:01 (1) new
Undefined index: company
/wp-content/plugins/wp-job-manager/includes/forms/class-wp-job-manager-form-submit-job.php(569) 2014-07-30 17:28:01 (1) new
Undefined index: company
/wp-content/plugins/wp-job-manager/includes/forms/class-wp-job-manager-form-submit-job.php(570) 2014-07-30 17:28:01 (1) new
Undefined index: company
/wp-content/plugins/wp-job-manager/includes/forms/class-wp-job-manager-form-submit-job.php(571) 2014-07-30 17:28:01 (1) new
Undefined index: company
/wp-content/plugins/wp-job-manager/includes/forms/class-wp-job-manager-form-submit-job.php(572) 2014-07-30 17:28:01 (1) new
Undefined index: company
/wp-content/plugins/wp-job-manager/includes/forms/class-wp-job-manager-form-submit-job.php(573) 2014-07-30 17:28:01 (1) new
Undefined index: company
/wp-content/plugins/wp-job-manager/includes/forms/class-wp-job-manager-form-submit-job.php(579) 2014-07-30 17:28:01 (1) new
Undefined index: company
/wp-content/plugins/wp-job-manager/includes/forms/class-wp-job-manager-form-submit-job.php(580) 2014-07-30 17:28:01 (1) new
Undefined index: company
/wp-content/plugins/wp-job-manager/includes/forms/class-wp-job-manager-form-submit-job.php(581) 2014-07-30 17:28:01 (1) new
Undefined index: company
/wp-content/plugins/wp-job-manager/includes/forms/class-wp-job-manager-form-submit-job.php(582) 2014-07-30 17:28:01 (1) new
Undefined index: company
/wp-content/plugins/wp-job-manager/includes/forms/class-wp-job-manager-form-submit-job.php(583) 2014-07-30 17:28:01 (1) new
Undefined index: job_location
/wp-content/plugins/wp-job-manager/includes/class-wp-job-manager-geocode.php(25) 2014-07-30 17:28:01 (1) new
Thanks
Not sure if this helps but here is the full code I’ve added to functions:
global $job_manager;
remove_action( 'job_manager_application_details_email', array( $job_manager->post_types, 'application_details_email' ) );
add_action( 'job_manager_application_details_email', 'my_job_application_form' );
function my_job_application_form () {
$author_email_addy = get_the_author_meta( 'user_email' );
$author_first_name = get_the_author_meta ('first_name');
gravity_form($id_or_title='Apply For Job', $display_title=true, $display_description=true, $display_inactive=false, $field_values = array('author_email'=> $author_email_addy,'author_greeting'=>$author_first_name), $ajax=false);
}
add_filter( 'submit_job_form_fields', 'custom_submit_job_form_fields' );
function custom_submit_job_form_fields( $fields ) {
unset( $fields ['company'] );
unset( $fields ['job']['job_location'] );
unset( $fields ['job']['application'] );
return $fields;
}
add_filter( 'submit_job_form_fields', 'frontend_add_new_fields' );
function frontend_add_new_fields( $fields ) {
$fields['job']['job_region'] = array(
'label' => 'Job Region',
'type' => 'select',
'required' => true,
'options' => array ( 0 => 'Choose a region', 'Bermuda' => 'Bermuda', 'Cayman Islands' => 'Cayman Islands', 'Other' => 'Other' ),
'placeholder' => '',
'priority' => 3
);
return $fields;
}
add_action( 'job_manager_update_job_data', 'frontend_add_region_field_save', 10, 2 );
function frontend_add_region_field_save( $job_id, $values ) {
update_post_meta( $job_id, '_job_region', $values['job']['job_region'] );
}
add_filter ('job_manager_job_listing_data_fields','admin_add_new_fields');
function admin_add_new_fields ($fields) {
$fields['_job_region'] = array(
'label' => __( 'Job Region', 'job_manager' ),
'type' => 'select',
'options' => array ( 0 => 'Choose a region', 'Bermuda' => 'Bermuda', 'Cayman Islands' => 'Cayman Islands', 'Other' => 'Other' ),
'placeholder' => '',
'description' => ''
);
return $fields;
}
These notices should be fixed in the next update.
Thanks
Thanks ever so much Mike.
So my code is fine????
Thanks for writing the plugin. It is truly one of the best.
A default salary field would make it out of this world. Especially if it had the ability to set a currency, rate (fixed and range), plus time period (hour, month, year).
Regards
Your code looks ok – there are just some cases where those fields were not checked to see if they exist.
Just be careful about removing the ‘application’ field – you’ll disable the ability to let people apply, or use add-ons which handle applications too.
Thanks
Regarding removing the application field.
I’m inserting a Gravity form on the single jobs page. Then I’m pulling the email address of the post author into a hidden field. Then using this to send any job submissions to the post author’s email address.
So I don’t believe I need the application field.
That should be fine, so long as the apply plugin you are using still shows up. Not all hooks are fired when application is missing.
That is true, if WP_Debug is disabled those warnings will not show (which it should always be disabled in production, at LEAST disable WP_Debug_Display)
You can get a free beta tester license for my field editor plugin that should remove those warnings from showing as even if it’s disabled I still have the field a part of the array so it’s just a blank value … get one here:
https://plugins.smyl.es/wp-job-manager-field-editor/