function wp_transition_comment_status($new_status, $old_status, $comment) {}

Call hooks for when a comment status transition occurs.
Calls hooks for comment status transitions. If the new comment status is not the same as the previous comment status, then two hooks will be ran, the first is ‘transition_comment_status’ with new status, old status, and comment data. The next action called is ‘comment_OLDSTATUS_to_NEWSTATUS’ the NEWSTATUS is the $new_status parameter and the OLDSTATUS is $old_status parameter; it has the comment data.


  • string $new_status: New comment status.
  • string $old_status: Previous comment status.
  • object $comment: Comment data.

Defined actions

  • transition_comment_status
    do_action('transition_comment_status', $new_status, $old_status, $comment);
  • comment_{$old_status}_to_{$new_status}
    do_action("comment_{$old_status}_to_{$new_status}", $comment);

Source code

function wp_transition_comment_status($new_status, $old_status, $comment) {

	// Translate raw statuses to human readable formats for the hooks

	// This is not a complete list of comment status, it's only the ones that need to be renamed

	$comment_statuses = array(

		0         => 'unapproved',

		'hold'    => 'unapproved', // wp_set_comment_status() uses "hold"

		1         => 'approved',

		'approve' => 'approved', // wp_set_comment_status() uses "approve"


	if ( isset($comment_statuses[$new_status]) ) $new_status = $comment_statuses[$new_status];

	if ( isset($comment_statuses[$old_status]) ) $old_status = $comment_statuses[$old_status];

	// Call the hooks

	if ( $new_status != $old_status ) {

		do_action('transition_comment_status', $new_status, $old_status, $comment);

		do_action("comment_{$old_status}_to_{$new_status}", $comment);


No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: