Codex tools: Log in
Transition the post status of a post.
This function calls hooks to transition a post's status. It does NOT change the status of the post. It only calls hooks to notify plugins, themes, and other core functions of the status change. To change the status of a post, use wp_update_post() or wp_publish_post().
This function is called after the status of a post has been changed to notify plugins, themes, and other core functions of the change by calling three actions.
The first is 'transition_post_status' with the new status, the old status, and the post data.
The next action called is 'OLDSTATUS_to_NEWSTATUS', where the 'NEWSTATUS' is the $new_status parameter and the 'OLDSTATUS' is $old_status parameter; it is passed the post object.
The final action is named 'NEWSTATUS_POSTTYPE', where 'NEWSTATUS' is from the $new_status parameter and 'POSTTYPE' is the post_type field from the $post data.
<?php wp_transition_post_status( $new_status, $old_status, $post ) ?>
The following example is based on wp_publish_post().
<?php global $wpdb; $post = get_post( $post ) if ( 'publish' == $post->post_status ) return; $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post->ID ) ); clean_post_cache( $post->ID ); $old_status = $post->post_status; $post->post_status = 'publish'; wp_transition_post_status( 'publish', $old_status, $post ); ?>
wp_transition_post_status() is located in
Post Status Transitions - More information on how to hook into the actions called by this function.