comment_<new_status>_<comment_type>

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

Description

do_action( 'comment_<new_status>_<comment_type>', (int) $comment_comment_id, (WP_Comment) $comment ); 

The dynamic portions of the hook name refer and $comment->comment_type,, refer to the new comment status, and the type of comment, respectively.

Typical comment types include an empty string (standard comment), pingback., or trackback.

Parameters (2)

0. $comment_comment_id (int)
The comment comment id.
1. $comment (WP_Comment)
Comment object.

Usage

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

Defined (1)

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

/wp-includes/comment.php  
  1. do_action( "comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment );