WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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) ) {
share|improve this question
up vote 11 down vote accepted

See this Codex page. In general the hook is {old_status}_to_{new_status}. (Untested) but in your case, the hook would be pending_to_draft:

 function wpse45803_pending_to_draft($post){
  //Do something

You might want to look up the wp_transition_post_status function. You could also use the hook: transition_post_status

 function wpse45803_transition_post_status($new_status,$old_status,$post){
  //Do something
share|improve this answer
Stephen, thank you a lot! I've read about Post Status Transitions before but I've missed that I can combine those statuses at will to get a hook. I'll try. Can't vote up because of low reputation... – Max Yudin Mar 16 '12 at 17:33
I think you can always up-vote, in any case you can accept an answer by clicking the tick next to it. (Please do this as it takes the question of the unanswered pile and means others with the same question can quickly find the 'correct' answer :D) – Stephen Harris Mar 16 '12 at 18:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.