Following up the ticket 'transition_post_status' is executed before 'save_post', I'm still struggling how to access the new $post
(after it has been saved) inside a transition_post_status
hook. Right now, I'm getting the old $post data (before it has been saved).
Example:
add_action('transition_post_status','myfunc',10,3);
function myfunc($new_status,$old_status,$post){
if ( $new_status == 'publish' && $old_status != 'publish') {
// a post is getting published
if(!check_my_post($post->ID)){ //how can I get the saved/new post here?
...
// do something
}
}
}
Changing priorities does not make any difference.
Any ideas how to achieve this?
save_post
one, both of them fire after data had been actually updated and should pass new instance. Your code not aligned with your assumptions somewhere.