Action hook 'wp_insert_comment'

in WP Core File wp-includes/comment.php at line 2123

View Source

wp_insert_comment

Action Hook
Description
Fires immediately after a comment is inserted into the database.

Hook Information

File Location wp-includes/comment.php View on GitHub
Hook Type Action
Line Number 2123

Hook Parameters

Type Name Description
int $id The comment ID.
WP_Comment $comment Comment object.

Usage Examples

Basic Usage
<?php
// Hook into wp_insert_comment
add_action('wp_insert_comment', 'my_custom_function', 10, 2);

function my_custom_function($id, $comment) {
    // Your custom code here
}

Source Code Context

wp-includes/comment.php:2123 - How this hook is used in WordPress core
<?php
2118  	 * @since 2.8.0
2119  	 *
2120  	 * @param int        $id      The comment ID.
2121  	 * @param WP_Comment $comment Comment object.
2122  	 */
2123  	do_action( 'wp_insert_comment', $id, $comment );
2124  
2125  	return $id;
2126  }
2127  
2128  /**

PHP Documentation

<?php
/**
	 * Fires immediately after a comment is inserted into the database.
	 *
	 * @since 2.8.0
	 *
	 * @param int        $id      The comment ID.
	 * @param WP_Comment $comment Comment object.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 2
  • File: wp-includes/comment.php
Related Hooks

Related hooks will be displayed here in future updates.