Update WP Job Manager Field on Save or Update (For saving value when used with Action Hook field type)

functions.php

<?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 );

}
No comments yet.

Leave a Reply