Title: wp_transition_comment_status
Published: April 25, 2014
Last modified: May 20, 2026

---

# wp_transition_comment_status( string $new_status, string $old_status, WP_Comment $comment )

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_transition_comment_status/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_transition_comment_status/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/wp_transition_comment_status/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_transition_comment_status/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_transition_comment_status/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_transition_comment_status/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_transition_comment_status/?output_format=md#wp--skip-link--target)

Calls hooks for when a comment status transition occurs.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_transition_comment_status/?output_format=md#description)󠁿

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’](https://developer.wordpress.org/reference/hooks/transition_comment_status/)
with new status, old status, and comment data.
The next action called is [‘comment_$old_status_to_$new_status’](https://developer.wordpress.org/reference/hooks/comment_old_status_to_new_status/).
It has the comment data.

The final action will run whether or not the comment statuses are the same.
The 
action is named [‘comment_$new_status_$comment->comment_type’](https://developer.wordpress.org/reference/hooks/comment_new_status_comment-comment_type/).

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_transition_comment_status/?output_format=md#parameters)󠁿

 `$new_status`stringrequired

New comment status.

`$old_status`stringrequired

Previous comment status.

`$comment`[WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/)
required

Comment object.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_transition_comment_status/?output_format=md#source)󠁿

    ```php
    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 ) {
    		/**
    		 * Fires when the comment status is in transition.
    		 *
    		 * @since 2.7.0
    		 *
    		 * @param string     $new_status The new comment status.
    		 * @param string     $old_status The old comment status.
    		 * @param WP_Comment $comment    Comment object.
    		 */
    		do_action( 'transition_comment_status', $new_status, $old_status, $comment );

    		/**
    		 * Fires when the comment status is in transition from one specific status to another.
    		 *
    		 * The dynamic portions of the hook name, `$old_status`, and `$new_status`,
    		 * refer to the old and new comment statuses, respectively.
    		 *
    		 * Possible hook names include:
    		 *
    		 *  - `comment_unapproved_to_approved`
    		 *  - `comment_spam_to_approved`
    		 *  - `comment_approved_to_unapproved`
    		 *  - `comment_spam_to_unapproved`
    		 *  - `comment_unapproved_to_spam`
    		 *  - `comment_approved_to_spam`
    		 *
    		 * @since 2.7.0
    		 *
    		 * @param WP_Comment $comment Comment object.
    		 */
    		do_action( "comment_{$old_status}_to_{$new_status}", $comment );
    	}
    	/**
    	 * Fires when the status of a specific comment type is in transition.
    	 *
    	 * The dynamic portions of the hook name, `$new_status`, and `$comment->comment_type`,
    	 * refer to the new comment status, and the type of comment, respectively.
    	 *
    	 * Typical comment types include 'comment', 'pingback', or 'trackback'.
    	 *
    	 * Possible hook names include:
    	 *
    	 *  - `comment_approved_comment`
    	 *  - `comment_approved_pingback`
    	 *  - `comment_approved_trackback`
    	 *  - `comment_unapproved_comment`
    	 *  - `comment_unapproved_pingback`
    	 *  - `comment_unapproved_trackback`
    	 *  - `comment_spam_comment`
    	 *  - `comment_spam_pingback`
    	 *  - `comment_spam_trackback`
    	 *
    	 * @since 2.7.0
    	 *
    	 * @param string     $comment_id The comment ID as a numeric string.
    	 * @param WP_Comment $comment    Comment object.
    	 */
    	do_action( "comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/comment.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/comment.php#L1871)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/comment.php#L1871-L1950)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_transition_comment_status/?output_format=md#hooks)󠁿

 [do_action( “comment_{$new_status}_{$comment->comment_type}”, string $comment_id, WP_Comment $comment )](https://developer.wordpress.org/reference/hooks/comment_new_status_comment-comment_type/)

Fires when the status of a specific comment type is in transition.

 [do_action( “comment_{$old_status}_to_{$new_status}”, WP_Comment $comment )](https://developer.wordpress.org/reference/hooks/comment_old_status_to_new_status/)

Fires when the comment status is in transition from one specific status to another.

 [do_action( ‘transition_comment_status’, string $new_status, string $old_status, WP_Comment $comment )](https://developer.wordpress.org/reference/hooks/transition_comment_status/)

Fires when the comment status is in transition.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_transition_comment_status/?output_format=md#related)󠁿

| Uses | Description | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  |

| Used by | Description | 
| [wp_set_comment_status()](https://developer.wordpress.org/reference/functions/wp_set_comment_status/)`wp-includes/comment.php` |

Sets the status of a comment.

  | 
| [wp_update_comment()](https://developer.wordpress.org/reference/functions/wp_update_comment/)`wp-includes/comment.php` |

Updates an existing comment in the database.

  | 
| [wp_delete_comment()](https://developer.wordpress.org/reference/functions/wp_delete_comment/)`wp-includes/comment.php` |

Trashes or deletes a comment.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_transition_comment_status/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.7.0](https://developer.wordpress.org/reference/since/2.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_transition_comment_status%2F)
before being able to contribute a note or feedback.