comment_post

Fires immediately after a comment is inserted into the database.

Description

do_action( 'comment_post', (int) $comment_id, (int|string) $commentdata_comment_approved, (array) $commentdata ); 

Parameters (3)

0. $comment_id (int)
The comment id.
1. $commentdata_comment_approved (int|string)
1 if the comment is approved, 0 if not, spam if spam.
2. $commentdata (array)
The commentdata.

Usage

To run the hook, copy the example below.
  1. // run the action 
  2. do_action( 'comment_post', $comment_id, $commentdata_comment_approved, $commentdata ); 
The following example is for adding a hook callback.
  1. // define the comment_post callback 
  2. function action_comment_post( $comment_id, $commentdata_comment_approved, $commentdata ) { 
  3. // make action magic happen here... 
  4. }; 
  5.  
  6. // add the action 
  7. add_action( 'comment_post', 'action_comment_post', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( 'comment_post', 'action_comment_post', 10, 3 ); 

Defined (1)

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

/wp-includes/comment.php  
  1. do_action( 'comment_post', $comment_ID, $commentdata['comment_approved'], $commentdata );