set_current_user()
set_current_user( int|null $id, string $name = ” ) 按ID或…
set_current_user( int|null $id, string $name = ” )
按ID或名称更改当前用户。
Changes the current user by ID or name.
按ID或名称更改当前用户。
Changes the current user by ID or name.
目录锚点:#说明#参数#源码
说明(Description)
如果不知道用户的id,请将$id设置为空并指定一个名称。另请参见wp_Set_current_user()
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $id | (int | null) | 用户ID。 |
| $name | (string) | 用户的用户名 |
源码(Source)
/**
* 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.
*
* @since 2.0.1
* @see wp_set_current_user() An alias of wp_set_current_user()
* @deprecated 3.0.0
* @deprecated Use wp_set_current_user()
*
* @param int|null $id User ID.
* @param string $name Optional. The user's username
* @return WP_User returns wp_set_current_user()
*/
function set_current_user($id, $name = '') {
_deprecated_function( __FUNCTION__, '3.0', 'wp_set_current_user()' );
return wp_set_current_user($id, $name);
}
endif;
if ( !function_exists('get_userdatabylogin') ) :| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 3.0.0 | wp-includes/pluggable-deprecated.php | 4 | 20 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!