I am trying to get the updated value of a piece of meta when a post is saved (custom post type) but when I try to grab the updated data on the save_post hook, I get the previous data instead. I tried a separate function with a higher priority, but no luck that way either (below)
How do I get the updated meta value right after I save the post?
Code:
add_action('save_post_space', 'tps_save_space_slots', 20, 3);
function tps_save_space_slots($post_id, $post, $updated) {
//Don't fire on auto-drafts
if (isset($post->post_status) && 'auto-draft' == $post->post_status) {
return;
}
//The new slots being saved
$allSlots = tps_generate_space_slots($post_id);
//Update the meta
$updateSlots = update_post_meta($post_id, 'allSlots', $allSlots);
}
add_action( 'save_post_space', 'tps_initiate_resend', 30, 3 );
function tps_initiate_resend($post_id, $post, $updated) {
tps_resend_code_after_change($post_id);//<----this sends the new meta value in an email, but it's the OLD value
}