WPDev.one
Core Function
View Source on Trac ↗

wp_set_current_user()

wp_set_current_user( mixed $id, mixed $name = '' )

Changes the current user by ID or name.

Parameters 1 required

Name / Type Description
(int

| null) $id User ID.

Required
$name
string

User's username.

Return Value

(WP_User)
Current user User object.

Function Information

Since Version
2.0.3
Source File
wp-includes/pluggable.php
Advertisement