get_userdata

Retrieve user info by user ID.

Description

(WP_User|false) get_userdata( (int) $user_id ); 

Returns (WP_User|false)

WP_User object on success, false on failure.

Parameters (1)

0. $user_id (int)
The user id.

Usage

  1. if ( !function_exists( 'get_userdata' ) ) { 
  2. require_once ABSPATH . WPINC . '/pluggable.php'; 
  3.  
  4. // The user id. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_userdata($user_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/pluggable.php  
  1. function get_userdata( $user_id ) { 
  2. return get_user_by( 'id', $user_id );