transition_post_status action-hookWP 2.3.0

Fires when a post is transitioned from one status to another.

Usage

add_action( 'transition_post_status', 'wp_kama_transition_post_status_action', 10, 3 );

/**
 * Function for `transition_post_status` action-hook.
 * 
 * @param string  $new_status New post status.
 * @param string  $old_status Old post status.
 * @param WP_Post $post       Post object.
 *
 * @return void
 */
function wp_kama_transition_post_status_action( $new_status, $old_status, $post ){

	// action...
}
$new_status(string)
New post status.
$old_status(string)
Old post status.
$post(WP_Post)
Post object.

Changelog

Since 2.3.0 Introduced.

Where the hook is called

wp_transition_post_status()
transition_post_status
wp-includes/post.php 5390
do_action( 'transition_post_status', $new_status, $old_status, $post );

Where the hook is used in WordPress

wp-includes/blocks/calendar.php 175
add_action( 'transition_post_status', 'block_core_calendar_update_has_published_post_on_transition_post_status', 10, 3 );
wp-includes/default-filters.php 417
add_action( 'transition_post_status', '_transition_post_status', 5, 3 );
wp-includes/default-filters.php 418
add_action( 'transition_post_status', '_update_term_count_on_transition_post_status', 10, 3 );
wp-includes/default-filters.php 441
add_action( 'transition_post_status', '_wp_auto_add_pages_to_menu', 10, 3 );
wp-includes/default-filters.php 528
add_action( 'transition_post_status', '_wp_customize_publish_changeset', 10, 3 );
wp-includes/default-filters.php 531
add_action( 'transition_post_status', '_wp_keep_alive_customize_changeset_dependent_auto_drafts', 20, 3 );
wp-includes/default-filters.php 543
add_action( 'transition_post_status', '__clear_multi_author_cache' );
wp-includes/ms-default-filters.php 80
add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 );
wp-includes/ms-default-filters.php 81
add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 );