Codex

Function Reference/get userdata

Contents

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

$userid
(integer) (required) The ID of the user whose data should be retrieved.
Default: None

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
  • description
  • user_level
  • admin_color (Theme of your admin page. Default is fresh.)
  • closedpostboxes_page
  • nickname
  • primary_blog
  • rich_editing
  • source_domain

See Also

Function_Reference/get_currentuserinfo, Author_Templates

This article is marked as in need of editing. You can help Codex by editing it.