setup_userdata() - WordPress 函数参考中文文档

返回介绍

setup_userdata()

发布于 2017-09-11 字数1593 浏览 884 评论 0

setup_userdata( int $for_user_id = '' )

Set up global user vars.


描述

Used by wp_set_current_user() for back compat. Might be deprecated in the future.


参数

$for_user_id
(int)
(Optional)
User ID to set up global data.

Default value: ”


源代码

File: wp-includes/user.php

function setup_userdata($for_user_id = '') {
	global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_identity;

	if ( '' == $for_user_id )
		$for_user_id = get_current_user_id();
	$user = get_userdata( $for_user_id );

	if ( ! $user ) {
		$user_ID = 0;
		$user_level = 0;
		$userdata = null;
		$user_login = $user_email = $user_url = $user_identity = '';
		return;
	}

	$user_ID    = (int) $user->ID;
	$user_level = (int) $user->user_level;
	$userdata   = $user;
	$user_login = $user->user_login;
	$user_email = $user->user_email;
	$user_url   = $user->user_url;
	$user_identity = $user->display_name;
}

更新日志

Version 描述
2.0.4 Introduced.

相关函数

Uses

  • wp-includes/pluggable.php:get_userdata()
  • wp-includes/user.php:get_current_user_id()

Used By

  • wp-includes/pluggable.php:wp_set_current_user()

上一篇:setup_postdata()

下一篇:set_current_screen()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!