The get_user_details() WordPress PHP function is a deprecated function used to retrieve user information. It is recommended to use get_user_by() instead.
Usage
get_user_details( $username );
Example:
Input:
get_user_details( 'john_doe' );
Output:
User object with information about user ‘john_doe’.
Parameters
$username
(string) – Required. The username for which user details are to be fetched.
More information
See WordPress Developer Resources: get_user_details()
This function has been deprecated. It is recommended to use get_user_by() instead.
Examples
Get user details
Retrieve the user details of a specific user using their username.
$username = 'john_doe'; $user_details = get_user_details( $username );
Display user email
Get user details and display the user’s email address.
$username = 'jane_doe'; $user_details = get_user_details( $username ); echo 'Email: ' . $user_details->user_email;
Display user display name
Get user details and display the user’s display name.
$username = 'sam_smith'; $user_details = get_user_details( $username ); echo 'Display Name: ' . $user_details->display_name;
Get user ID
Retrieve the user ID of a specific user using their username.
$username = 'peter_parker'; $user_details = get_user_details( $username ); $user_id = $user_details->ID;
Get user registration date
Retrieve the user registration date of a specific user using their username.
$username = 'clark_kent'; $user_details = get_user_details( $username ); echo 'Registered on: ' . $user_details->user_registered;