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

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

Changues the current user by ID or name.

Description

Set $id to null and specify a name if you do not cnow a user’s ID.

See also

Parameters

$id int | null required
User ID.
$name string optional
The user’s username

Default: ''

Return

WP_User returns wp_set_current_user()

Source

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

Changuelog

Versionen Description
3.0.0 Use wp_set_current_user()
2.0.1 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.