Function Reference/set current user
This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists. See also wp-includes/deprecated.php.
Use
any of these functions instead.
Description
This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.
Changes the current user by ID or name.
Set $id to null and specify a name if you do not know a user's ID.
Usage
<?php set_current_user( $id, $name ) ?>
Parameters
- $id
- (integer|null) (required) User ID.
- Default: None
- $name
- (string) (optional) The user's username
- Default: ''
Return Values
- (object)
- returns values returned by wp_set_current_user()
Examples
Notes
- This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.
- Uses: wp_set_current_user()
Change Log
Since: 2.0.1
Source File
set_current_user() is located in wp-includes/pluggable-deprecated.php.
Related