Last active
March 31, 2016 16:13
-
-
Save tripflex/ca118e942cb4fc3e47c76ac411356aea to your computer and use it in GitHub Desktop.
Update WP Job Manager Field on Save or Update (For saving value when used with Action Hook field type)
This file contains 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 | |
/* | |
* Save/Update Listing when Save/Update from Frontend | |
*/ | |
add_action( 'job_manager_update_job_data', 'smp920_update_my_fields', 100, 2 ); | |
function smp920_update_my_fields( $job_id, $values ){ | |
// Check for value in $_POST, then set var with sanitized value, CHANGE my_input_name to the NAME used in the input HTML element | |
$my_input_name = isset( $_POST['my_input_name'] ) ? sanitize_text_field( $_POST['my_input_name'] ) : false; | |
// Update the listing with the value, !! ALL META KEYS SHOULD BE PREPENDED WITH AN UNDERSCORE !!! | |
if( $my_input_name ) update_post_meta( $job_id, '_my_meta_key', $my_input_name ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment