This page redirects to an external site: https://developer.wordpress.org/reference/hooks/comment_post/
comment_post is an action triggered immediately after a comment is inserted into the database.
Note: This page will be superseded by the following page in the Code Reference: https://developer.wordpress.org/reference/hooks/comment_post/
The following example allows you to do something immediately after a comment is posted. In this case we are checking whether the comment is approved before adding our function logic.
add_action( 'comment_post', 'show_message_function', 10, 2 );
function show_message_function( $comment_ID, $comment_approved ) {
if( 1 === $comment_approved ){
//function logic goes here
}
}
Triggered by wp_new_comment in wp-includes/comment.php