get_currentuserinfo()获取当前登录用户的个人信息

目录

描述

译文

检索当前登录用户的相关信息,并将信息置入$userdata全局变量。函数属性直接映射到数据库(参见Database Description)中的wp_usrs表格。

同样也将个体属性放置到以下独立全局变量中:

  • $user_login
  • $user_level
  • $user_ID
  • $user_email
  • $user_url(用户在用户资料中输入的网址)
  • $user_pass_md5 (用户密码的md5 hash——一种几乎无法解密(不是完全无法解密)的编码,可比较输入提示口令与实际用户密码的不同)
  • $display_name(用户名,根据'How to display name'用户选项结果进行显示)

原文

Retrieves the information pertaining to the currently logged in user, and places it in the global variable $userdata. Properties map directly to the wp_users table in the database (see Database Description).

Also places the individual attributes into the following separate global variables:

  • $user_login
  • $user_level
  • $user_ID
  • $user_email
  • $user_url (User's website, as entered in the user's Profile)
  • $user_pass_md5 (A md5 hash of the user password -- a type of encoding that is very nearly, if not entirely, impossible to decode, but useful for comparing input at a password prompt with the actual user password.)
  • $display_name (User's name, displayed according to the 'How to display name' User option)

get_currentuserinfo() 描述

用法

 <?php get_currentuserinfo(); ?> 

get_currentuserinfo() 用法

示例

Default Usage

The call to get_currentuserinfo() places the current user's info into $userdata, where it can be retrieved using member variables.

Username: Zedd

User email: my@email.com
User level: 10
User first name: John
User last name: Doe
User display name: John Doe

User ID: 1

Using Separate Globals

Much of the user data is placed in separate global variables, which can be accessed directly.

Zedd's email address is: fake@email.com

: NOTE: $display_name does not appear to work in 2.5+? $user_login works fine.

get_currentuserinfo() 示例