determine_current_user
Filter HookDescription
Filters the current user. The default filters use this to determine the current user from the request's cookies, if available. Returning a value of false will effectively short-circuit setting the current user.Hook Information
File Location |
wp-includes/user.php
View on GitHub
|
Hook Type | Filter |
Line Number | 3753 |
Hook Parameters
Type | Name | Description |
---|---|---|
int|false
|
$user_id
|
User ID if one has been determined, false otherwise. |
Usage Examples
Basic Usage
<?php
// Hook into determine_current_user
add_filter('determine_current_user', 'my_custom_filter', 10, 1);
function my_custom_filter($user_id) {
// Your custom filtering logic here
return $user_id;
}
Source Code Context
wp-includes/user.php:3753
- How this hook is used in WordPress core
<?php
3748 *
3749 * @since 3.9.0
3750 *
3751 * @param int|false $user_id User ID if one has been determined, false otherwise.
3752 */
3753 $user_id = apply_filters( 'determine_current_user', false );
3754 if ( ! $user_id ) {
3755 wp_set_current_user( 0 );
3756 return $current_user;
3757 }
3758
PHP Documentation
<?php
/**
* Filters the current user.
*
* The default filters use this to determine the current user from the
* request's cookies, if available.
*
* Returning a value of false will effectively short-circuit setting
* the current user.
*
* @since 3.9.0
*
* @param int|false $user_id User ID if one has been determined, false otherwise.
*/
Quick Info
- Hook Type: Filter
- Parameters: 1
- File: wp-includes/user.php
Related Hooks
Related hooks will be displayed here in future updates.