WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/set current user


This function has been deprecated since Version 3.0. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists. See also wp-includes/deprecated.php. Use wp_set_current_user instead.

Contents

Description

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

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.

Usage

<?php set_current_user$id$name ?>

Parameters

$id
(integer|null) (required) User ID.
Default: None
$name
(string) (optional) The user's username
Default: ''

Return Values

(object) 
returns values returned by wp_set_current_user()

Examples

Notes

  • This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.
  • Uses: wp_set_current_user()

Change Log

Source File

set_current_user() is located in wp-includes/pluggable-deprecated.php. Before deprecation it was located in wp-includes/pluggable.php.

Related

Current User Functions: get_current_user_id(), get_currentuserinfo(), wp_get_current_user(), wp_set_current_user(), current_user_can(), current_user_can_for_blog()

See also index of Function Reference and index of Template Tags.