Skip to content

Instantly share code, notes, and snippets.

@tripflex
Last active March 31, 2016 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tripflex/ca118e942cb4fc3e47c76ac411356aea to your computer and use it in GitHub Desktop.
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)
<?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