comment_<old_status>_to_<new_status>

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

Description

do_action( 'comment_<old_status>_to_<new_status>', (WP_Comment) $comment ); 

The dynamic portions of the hook name refer and $new_status,, refer to the old and new comment statuses, respectively.

Parameters (1)

0. $comment (WP_Comment)
Comment object.

Usage

To run the hook, copy the example below.
  1. // run the action 
  2. do_action( 'comment_{$old_status}_to_{$new_status}', $comment ); 
The following example is for adding a hook callback.
  1. // define the comment_<old_status>_to_<new_status> callback 
  2. function action_comment_old_status_to_new_status( $comment ) { 
  3. // make action magic happen here... 
  4. }; 
  5.  
  6. // add the action 
  7. add_action( "comment_{$old_status}_to_{$new_status}", 'action_comment_old_status_to_new_status', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( "comment_{$old_status}_to_{$new_status}", 'action_comment_old_status_to_new_status', 10, 1 ); 

Defined (1)

The action is defined in the following location(s).

/wp-includes/comment.php  
  1. do_action( "comment_{$old_status}_to_{$new_status}", $comment );