add_action( 'job_bm_registration_form', 'job_bm_registration_form_26072019', 15 ); if ( ! function_exists( 'job_bm_registration_form_26072019' ) ) { function job_bm_registration_form_26072019(){ ?> <pre>Content inside form</pre> <?php } }
Display custom input field
add_action( 'job_bm_registration_form', 'job_bm_registration_form_29072019', 5 ); if ( ! function_exists( 'job_bm_registration_form_29072019' ) ) { function job_bm_registration_form_29072019($job_id){ ?> <div class="form-field-wrap"> <div class="field-title">Custom field</div> <div class="field-input"> <input placeholder="custom placeholder" type="text" value="" name="custom_field_id"> <p class="field-details">Custom field details</p> </div> </div> <?php } }
Validate custom field data
add_filter('job_bm_registration_errors', 'job_bm_registration_errors_custom_field_29072019', 10,2); function job_bm_registration_errors_custom_field_29072019($error, $form_data){ if(empty($form_data['custom_field_id'])){ $error->add( 'custom_field_id', __( '<strong>ERROR</strong>: custom field is empty.', 'job-board-manager' ) ); } return $error; }
Save data
add_filter('job_bm_registration_completed', 'job_bm_registration_completed_custom_field_29072019', 10,2); function job_bm_registration_completed_custom_field_29072019($user_id){ $custom_field_value = isset($post_data['custom_field_id']) ? sanitize_text_field($form_data['custom_field_id']) : ""; update_user_meta($user_id, 'custom_field_id', $custom_field_value ); }