comment_post action-hookWP 1.2.0

Fires immediately after a comment is inserted into the database.

Usage

add_action( 'comment_post', 'wp_kama_comment_post_action', 10, 3 );

/**
 * Function for `comment_post` action-hook.
 * 
 * @param int        $comment_id       The comment ID.
 * @param int|string $comment_approved 1 if the comment is approved, 0 if not, 'spam' if spam.
 * @param array      $commentdata      Comment data.
 *
 * @return void
 */
function wp_kama_comment_post_action( $comment_id, $comment_approved, $commentdata ){

	// action...
}
$comment_id(int)
The comment ID.
$comment_approved(int|string)
1 if the comment is approved, 0 if not, 'spam' if spam.
$commentdata(array)
Comment data.

Changelog

Since 1.2.0 Introduced.
Since 4.5.0 The $commentdata parameter was added.

Where the hook is called

wp_new_comment()
comment_post
wp-includes/comment.php 2320
do_action( 'comment_post', $comment_id, $commentdata['comment_approved'], $commentdata );

Where the hook is used in WordPress

wp-includes/default-filters.php 503
add_action( 'comment_post', 'wp_new_comment_notify_moderator' );
wp-includes/default-filters.php 504
add_action( 'comment_post', 'wp_new_comment_notify_postauthor' );