The get_user_to_edit() WordPress PHP function retrieves user data and filters it.
Usage
$filtered_user = get_user_to_edit($user_id);
Example:
$user_id = 1; $filtered_user = get_user_to_edit($user_id); echo '<pre>'; print_r($filtered_user); echo '</pre>';
Parameters
$user_id
(int) (required) – The User ID of the user you want to retrieve and filter data for.
More information
See WordPress Developer Resources: get_user_to_edit
Examples
Displaying Filtered User Information
Retrieve filtered user data and display the user’s display name, email, and bio.
$user_id = 1; $filtered_user = get_user_to_edit($user_id); echo 'Display Name: ' . $filtered_user->display_name . '<br>'; echo 'Email: ' . $filtered_user->user_email . '<br>'; echo 'Bio: ' . $filtered_user->description;
Displaying a User’s First and Last Name
Retrieve filtered user data and display the user’s first and last name.
$user_id = 2; $filtered_user = get_user_to_edit($user_id); echo 'First Name: ' . $filtered_user->first_name . '<br>'; echo 'Last Name: ' . $filtered_user->last_name;
Displaying a User’s Website URL
Retrieve filtered user data and display the user’s website URL.
$user_id = 3; $filtered_user = get_user_to_edit($user_id); echo 'Website: ' . $filtered_user->user_url;
Displaying a User’s Role
Retrieve filtered user data and display the user’s role.
$user_id = 4; $filtered_user = get_user_to_edit($user_id); $user_role = implode(', ', $filtered_user->roles); echo 'Role: ' . $user_role;
Displaying a User’s Registration Date
Retrieve filtered user data and display the user’s registration date.
$user_id = 5; $filtered_user = get_user_to_edit($user_id); echo 'Registration Date: ' . $filtered_user->user_registered;