我试图在保存帖子(自定义帖子类型)时获取一段元数据的更新值,但当我试图在save\\u post挂钩上获取更新的数据时,我会获取以前的数据。我尝试了一个优先级更高的单独函数,但也没有成功(见下文)
如何在保存帖子后立即获得更新后的元数据?
代码:
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
}