On this page
set_current_user( int|null $id, string $name = '' ): WP_User
This function has been deprecated. Use wp_set_current_user() instead.
Changes the current user by ID or name.
Description
Set $id to null and specify a name if you do not know a user’s ID.
See also
Parameters
$idint|null Required-
User ID.
$namestring Optional-
The user's username
Default:
''
Return
WP_User returns wp_set_current_user()
Source
File: wp-includes/pluggable-deprecated.php. View all references
function set_current_user($id, $name = '') {
_deprecated_function( __FUNCTION__, '3.0.0', 'wp_set_current_user()' );
return wp_set_current_user($id, $name);
}
Related
Uses
| Uses | Description |
|---|---|
| wp_set_current_user() wp-includes/pluggable.php | Changes the current user by ID or name. |
| _deprecated_function() wp-includes/functions.php | Marks a function as deprecated and inform when it has been used. |
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Use wp_set_current_user() |
| 2.0.1 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/set_current_user