Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Action Reference/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 comment that is created.
1 (true) if the comment is approved, 0 (false) if not


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

Source File

Triggered by wp_new_comment in wp-includes/comment.php

This page is marked as incomplete. You can help Codex by expanding it.