wp_set_current_user


wp_set_current_user ( $id, $name = '' )

Parameters:
  • (int|null) id User ID.
  • (string) name User's username.
Returns:
  • (WP_User) Current user User object.
Defined at:

Description

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. Some WordPress functionality is based on the current user and not based on the signed in user. Therefore, it opens the ability to edit and perform actions on users who aren't signed in.

Related Functions

wp_get_current_user, _wp_get_current_user, set_current_user, get_current_user_id, set_current_screen

Top Google Results

User discussions

wpseek mobile