WordPress:Function Reference/get userdata

来自站长百科
Xxf3325讨论 | 贡献2008年7月19日 (六) 11:46的版本 (新页面: == Description == Returns an object with the information pertaining to the user whose ID is passed to it. Properties map directly to wp_users table in the database (see [[WordPress:Datab...)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航、​ 搜索

Description

Returns an object with the information pertaining to the user whose ID is passed to it. Properties map directly to wp_users table in the database (see Database Description).

Usage

%%% <?php get_userdata(userid); ?> %%%

Examples

Default Usage

The call to get_userdata() returns the user's data, where it can be retrieved using member variables.

<?php $user_info = get_userdata(1);

      echo('Username: ' . $user_info->user_login . '\n');
      echo('User level: ' . $user_info->user_level . '\n');
      echo('User ID: ' . $user_info->ID . '\n');
?>
Username: admin

User level: 10

User ID: 1

Accessing Usermeta Data

<?php $user_info = get_userdata(1);

      echo($user_info->last_name .  ", " . $user_info->first_name . "\n");
?>

Blow, Joe

Parameters

Values in users & user_meta table

Here are the values in the users table you can access via this function:

users

ID
user_login
user_pass
user_nicename
user_email
user_url
user_registered
user_activation_key
user_status
display_name

useful in user_meta

first_name
last_name
nickname
user_level

See Also

WordPress:Function_Reference/get_currentuserinfo