Filter hook 'pre_user_id'

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

View Source

pre_user_id

Filter Hook
Description
Filters the comment author's user ID before it is set. The first time this filter is evaluated, `user_ID` is checked (for back-compat), followed by the standard `user_id` value.

Hook Information

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

Hook Parameters

Type Name Description
int $user_id The comment author's user ID.

Usage Examples

Basic Usage
<?php
// Hook into pre_user_id
add_filter('pre_user_id', 'my_custom_filter', 10, 1);

function my_custom_filter($user_id) {
    // Your custom filtering logic here
    return $user_id;
}

Source Code Context

wp-includes/comment.php:2155 - How this hook is used in WordPress core
<?php
2150  		 * @param int $user_id The comment author's user ID.
2151  		 */
2152  		$commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_ID'] );
2153  	} elseif ( isset( $commentdata['user_id'] ) ) {
2154  		/** This filter is documented in wp-includes/comment.php */
2155  		$commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_id'] );
2156  	}
2157  
2158  	/**
2159  	 * Filters the comment author's browser user agent before it is set.
2160  	 *

PHP Documentation

<?php
/**
		 * Filters the comment author's user ID before it is set.
		 *
		 * The first time this filter is evaluated, `user_ID` is checked
		 * (for back-compat), followed by the standard `user_id` value.
		 *
		 * @since 1.5.0
		 *
		 * @param int $user_id The comment author's user ID.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/comment.php
Related Hooks

Related hooks will be displayed here in future updates.