Add custom input field under job submit form
add_action('job_bm_job_submit_form', 'job_bm_job_submit_form_custom_form_field', 8); function job_bm_job_submit_form_custom_form_field(){ $custom_form_field = isset($_POST['custom_form_field']) ? sanitize_text_field($_POST['custom_form_field']) : ""; ?> <div class="form-field-wrap"> <div class="field-title"><?php echo __('Custom Form Field','job-board-manager'); ?></div> <div class="field-input"> <input placeholder="" type="text" value="<?php echo $custom_form_field; ?>" name="custom_form_field"> <p class="field-details"><?php _e('Details custom form field','job-board-manager'); ?></p> </div> </div> <?php }
Validated custom form field
add_filter('job_bm_job_submit_errors', 'job_bm_job_submit_errors_custom_form_field', 90,2); function job_bm_job_submit_errors_custom_form_field($error, $post_data){ if(empty($post_data['custom_form_field'])){ $error->add( 'custom_form_field', __( 'ERROR: Field is empty.', 'job-board-manager' ) ); } return $error; }
Save custom form field data
add_filter('job_bm_job_submitted', 'job_bm_job_submitted_custom_form_field', 90,2); function job_bm_job_submitted_custom_form_field($job_ID, $post_data){ $custom_form_field = isset($post_data['custom_form_field']) ? sanitize_text_field($post_data['custom_form_field']) : ""; update_post_meta($job_ID, 'custom_form_field', $custom_form_field); }