<old_status>_to_<new_status>
Fires when a post is transitioned from one status to another.
Description
The dynamic portions of the hook name refer refer to the old and new post statuses, respectively.
Parameters (1)
- 0. $post (WP_Post)
- Post object.
Usage
- To run the hook, copy the example below.
- // run the action
- do_action( '{$old_status}_to_{$new_status}', $post );
- The following example is for adding a hook callback.
- // define the <old_status>_to_<new_status> callback
- function action_old_status_to_new_status( $post ) {
- // make action magic happen here...
- };
- // add the action
- add_action( "{$old_status}_to_{$new_status}", 'action_old_status_to_new_status', 10, 1 );
- To remove a hook callback, use the example below.
- // remove the action
- remove_action( "{$old_status}_to_{$new_status}", 'action_old_status_to_new_status', 10, 1 );
Defined (1)
The action is defined in the following location(s).
- /wp-includes/post.php
- do_action( "{$old_status}_to_{$new_status}", $post );