I can hook custom function to each of trash_post
, edit_post
, private_to_publish
etc. to meet some of my requirements, but I need also to check for more possible transitions like ‘pending to draft’, ‘private to draft’ and so on.
Something similar to this inexistent function:
if( post_status_changed($post_id) ) {
my_custom_function();
}
See this Codex page. In general the hook is
{old_status}_to_{new_status}
. (Untested) but in your case, the hook would bepending_to_draft
:You might want to look up the
wp_transition_post_status
function. You could also use the hook:transition_post_status