Action hook 'pre_comment_on_post'

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

View Source

pre_comment_on_post

Action Hook
Description
Fires before a comment is posted.

Hook Information

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

Hook Parameters

Type Name Description
int $comment_post_id Post ID.

Usage Examples

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

function my_custom_function($comment_post_id) {
    // Your custom code here
}

Source Code Context

wp-includes/comment.php:3670 - How this hook is used in WordPress core
<?php
3665  		 *
3666  		 * @since 2.8.0
3667  		 *
3668  		 * @param int $comment_post_id Post ID.
3669  		 */
3670  		do_action( 'pre_comment_on_post', $comment_post_id );
3671  	}
3672  
3673  	// If the user is logged in.
3674  	$user = wp_get_current_user();
3675  	if ( $user->exists() ) {

PHP Documentation

<?php
/**
		 * Fires before a comment is posted.
		 *
		 * @since 2.8.0
		 *
		 * @param int $comment_post_id Post ID.
		 */
Quick Info
  • Hook Type: Action
  • Parameters: 1
  • File: wp-includes/comment.php
Related Hooks

Related hooks will be displayed here in future updates.