Last active
November 20, 2025 21:51
-
-
Save tripflex/fab8b3d33833ea6edb844722093e742e to your computer and use it in GitHub Desktop.
Allow zero value fields support for NUMBER field type in WP Job Manager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'submit_job_form_fields', 'smyles_allow_zero_value_field' ); | |
| function smyles_allow_zero_value_field( $fields ){ | |
| $fields['job']['METAKEY']['before_sanitize'] = true; | |
| return $fields; | |
| } | |
| add_filter( 'job_manager_get_posted_number_field', 'smyles_allow_zero_value_number_field_handler' ); | |
| function smyles_allow_zero_value_number_field_handler(){ | |
| return 'smyles_allow_zero_value_number_field'; | |
| } | |
| function smyles_allow_zero_value_number_field( $key, $field ){ | |
| if( isset( $_POST[ $key ] ) ){ | |
| return sanitize_text_field( $_POST[ $key ] ); | |
| } | |
| return ''; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'submit_resume_form_fields', 'smyles_allow_resume_zero_value_field' ); | |
| function smyles_allow_resume_zero_value_field( $fields ){ | |
| $fields['resume_fields']['METAKEY']['before_sanitize'] = true; | |
| return $fields; | |
| } | |
| add_filter( 'job_manager_get_posted_number_field', 'smyles_allow_zero_value_number_field_handler' ); | |
| function smyles_allow_zero_value_number_field_handler(){ | |
| return 'smyles_allow_zero_value_number_field'; | |
| } | |
| function smyles_allow_zero_value_number_field( $key, $field ){ | |
| if( isset( $_POST[ $key ] ) ){ | |
| return sanitize_text_field( $_POST[ $key ] ); | |
| } | |
| return ''; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
New alternative approach for WP Job Manager 1.36.0+
https://gist.github.com/tripflex/a467508965eff64f13f94de55b7636b4