Codex

Function Reference/set current user

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

Since: 2.0.1

Source File

set_current_user() is located in wp-includes/pluggable.php.

Related