I don’t know how to force this function to run as the last function after all other save things from WP are executed.
This is my current code in my plugin:
add_action( 'save_post', 'do_custom_save' );
function do_custom_save( $post_id ) {
// No auto saves
if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
// make sure the current user can edit the post
if( ! current_user_can( 'edit_post' ) ) return;
// assure the post type
if ( ! get_post_type($post_id) == 'post' ) return;
$latitude = $_POST['rw_company_latitude'];
$longitude = $_POST['rw_company_longitude'];
$zoom = '6';
$lat_lon_zoom = $latitude . ', ' . $longitude . ', ' . $zoom ;
update_post_meta($post_id, 'company_map', $lat_lon_zoom );
}
How to force this code to be executed and saved the mixed variable as the last thing? After all the other saving and updating is done.
Because right now it’s updated ok, but then again rewritten by the value from original map field $_POST[‘company_map’]. I need to somehow tell WP that this function should run as the last function when performing saving/updating post stuff.
How to do that?