This function has been deprecated. Use wp_set_current_user() instead.

set_current_user( int|null $id, string $name = '' )

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

$id

(int|null) (Required) User ID.

$name

(string) (Optional) The user's username

Default value: ''


Return

(WP_User) returns wp_set_current_user()


Source

File: wp-includes/pluggable-deprecated.php

function set_current_user($id, $name = '') {
	_deprecated_function( __FUNCTION__, 'WP-3.0.0', 'wp_set_current_user()' );
	return wp_set_current_user($id, $name);
}


Changelog

Changelog
Version Description
WP-3.0.0 Use wp_set_current_user()
WP-2.0.1 Introduced. This function has been deprecated. Use wp_set_current_user() instead.