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