Returns an object with the information pertaining to the user whose ID is passed to it. Properties map directly to wp_users and wp_usermeta tables in the database (see Database Description).
If the user does not exist, the function returns false.

Usage
<?php get_userdata( $userid ); ?>
Parameters
$userid
(integer) (required) The ID of the user whose data should be retrieved.
Default: None
Return values: (bool|object)
False on failure, WP_User object on success
Examples
1. Default Usage
get_userdata() returns an object of the user’s data that you can assign to a variable. After that, you can echo various parts of the returned object or loop through the data to display it all.
2.Example displaying certain parts:
<?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";
?>
Results in:
Username: admin
User level: 10
User ID: 1
You can also assign certain parts into individual variables for displaying later or in multiple places.
More info: http://codex.wordpress.org/Function_Reference/get_userdata


Leave a comment