Anyone Can Type Here: The 3 Hooks That Decide What a WordPress Comment Becomes
The Problem A comment form is the one place on most WordPress sites where an anonymous visitor’s text ends up stored in the database and rendered back to…

Action Hook since 1.2.0
Fires immediately after a comment is inserted
comment_post fires right after a new comment saves — the standard place to trigger notifications or moderation logic.
Front-end, after wp_new_comment() validates and inserts the comment via wp_insert_comment(). Fires for both approved and held-for-moderation comments.
do_action( 'comment_post', int $comment_id, int|string $comment_approved, array $comment_data );$comment_id int — The new comment's ID.$comment_approved int|string — 1 (approved), 0 (pending), or 'spam'.$comment_data array — Raw comment data that was inserted.add_action( 'comment_post', function( $comment_id, $approved ) {
if ( 1 === $approved ) {
wp_mail( get_option( 'admin_email' ), 'New comment', 'A comment was just approved.' );
}
}, 10, 2 );Notify the admin only when a comment is auto-approved.
add_action( 'comment_post', function( $comment_id, $approved, $data ) {
if ( preg_match( '/https?:///', $data['comment_content'] ) ) {
wp_set_comment_status( $comment_id, 'hold' );
}
}, 10, 3 );Auto-hold any comment containing a link for manual review.

The Problem A comment form is the one place on most WordPress sites where an anonymous visitor’s text ends up stored in the database and rendered back to…
1 for approved, 0 for pending moderation, or the string 'spam' — check it before triggering notifications so you don't email admins about spam.
Source: wp-includes/comment.php
One session: this hook, then each related_hooks entry. Walk it and tell us what to change.
comment_post → comment_text
Practice the comment_post WordPress action hook in our interactive sandbox — a VS Code-style editor with a step-by-step comment_post tutorial, add_action exercises, and instant feedback. No local WordPress install required.