get_user()wp-includes/user.php |
Retrieves user info by user ID.
|
WP_REST_Templates_Controller::get_wp_templates_author_text_field()wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php |
Returns a human readable text for the author of the template.
|
wpmu_new_site_admin_notification()wp-includes/ms-functions.php |
Notifies the Multisite network administrator that a new site was created.
|
wp_authenticate_application_password()wp-includes/user.php |
Authenticates the user using an application password.
|
WP_Automatic_Updater::send_plugin_theme_email()wp-admin/includes/class-wp-automatic-updater.php |
Sends an email upon the completion or failure of a plugin or theme background update.
|
populate_network_meta()wp-admin/includes/schema.php |
Creates WordPress network meta and sets the default values.
|
get_object_subtype()wp-includes/meta.php |
Returns the object subtype for a given object ID of a specific type.
|
wp_create_user_request()wp-includes/user.php |
Creates and logs a user request to perform a specific action.
|
wp_user_personal_data_exporter()wp-includes/user.php |
Finds and exports personal data associated with an email address from the user and user_meta table.
|
wp_media_personal_data_exporter()wp-includes/media.php |
Finds and exports attachments associated with an email address.
|
_wp_personal_data_handle_actions()wp-admin/includes/privacy-tools.php |
Handle list table actions.
|
get_user_locale()wp-includes/l10n.php |
Retrieves the locale of a user.
|
WP_REST_Users_Controller::create_item()wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php |
Creates a single user.
|
WP_REST_Users_Controller::update_item()wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php |
Updates a single user.
|
wp_authenticate_email_password()wp-includes/user.php |
Authenticates a user using the email and password.
|
get_avatar_data()wp-includes/link-template.php |
Retrieves default data about the avatar.
|
retrieve_password()wp-includes/user.php |
Handles sending a password retrieval email to a user.
|
WP_Automatic_Updater::send_email()wp-admin/includes/class-wp-automatic-updater.php |
Sends an email upon the completion or failure of a background core update.
|
WP_Automatic_Updater::send_debug_email()wp-admin/includes/class-wp-automatic-updater.php |
Prepares and sends an email of a full log of background update results, useful for debugging and geekery.
|
wp_password_change_notification()wp-includes/pluggable.php |
Notifies the blog admin of a user changing password, normally via email.
|
wp_new_user_notification()wp-includes/pluggable.php |
Emails login credentials to a newly-registered user.
|
wp_notify_postauthor()wp-includes/pluggable.php |
Notifies an author (and/or others) of a comment/trackback/pingback on a post.
|
wp_notify_moderator()wp-includes/pluggable.php |
Notifies the moderator of the site about a new comment that is awaiting approval.
|
wp_validate_auth_cookie()wp-includes/pluggable.php |
Validates authentication cookie.
|
get_userdata()wp-includes/pluggable.php |
Retrieves user info by user ID.
|
get_profile()wp-includes/deprecated.php |
Retrieve user data based on field.
|
WP_Query::get_queried_object()wp-includes/class-wp-query.php |
Retrieves the currently queried object.
|
WP_Query::get_posts()wp-includes/class-wp-query.php |
Retrieves an array of posts based on query variables.
|
check_password_reset_key()wp-includes/user.php |
Retrieves a user row based on password reset key and login.
|
username_exists()wp-includes/user.php |
Determines whether the given username exists.
|
email_exists()wp-includes/user.php |
Determines whether the given email exists.
|
wp_authenticate_username_password()wp-includes/user.php |
Authenticates a user, confirming the username and password are valid.
|
get_userdatabylogin()wp-includes/pluggable-deprecated.php |
Retrieve user info by login name.
|
get_user_by_email()wp-includes/pluggable-deprecated.php |
Retrieve user info by email.
|
wp_setcookie()wp-includes/pluggable-deprecated.php |
Sets a cookie for a user who just logged in. This function is deprecated.
|
get_pages()wp-includes/post.php |
Retrieves an array of pages (or hierarchical post type items).
|
is_user_spammy()wp-includes/ms-functions.php |
Determines whether a user is marked as a spammer, based on user login.
|
wpmu_signup_blog_notification()wp-includes/ms-functions.php |
Sends a confirmation request email to a user when they sign up for a new site. The new site will not become active until the confirmation link is clicked.
|
wpmu_signup_user_notification()wp-includes/ms-functions.php |
Sends a confirmation request email to a user when they sign up for a new user account (without signing up for a site at the same time). The user account will not become active until the confirmation link is clicked.
|
is_site_admin()wp-includes/ms-deprecated.php |
Determine if user is a site admin.
|
get_user_details()wp-includes/ms-deprecated.php |
Deprecated functionality to retrieve user information.
|
get_user_id_from_string()wp-includes/ms-deprecated.php |
Get a numeric user ID from either an email address or a login.
|
check_comment()wp-includes/comment.php |
Checks whether a comment passes internal checks to be allowed to add.
|
Skip to note 8 content
Codex
Sample response of
$author_obj = get_user_by('id', 1);<br />
object(WP_User)#96 (7) {<br />
["data"]=><br />
object(stdClass)#95 (10) {<br />
["ID"]=><br />
string(1) "1"<br />
["user_login"]=><br />
string(10) "superadmin"<br />
["user_pass"]=><br />
string(34) "$P$Bx0Jgq6/Qw/o3A5fXcVKg4jxQr2PAB1"<br />
["user_nicename"]=><br />
string(10) "superadmin"<br />
["user_email"]=><br />
string(16) "user@example.com"<br />
["user_url"]=><br />
string(0) ""<br />
["user_registered"]=><br />
string(19) "2014-02-21 21:31:40"<br />
["user_activation_key"]=><br />
string(0) ""<br />
["user_status"]=><br />
string(1) "0"<br />
["display_name"]=><br />
string(10) "superadmin"<br />
}<br />
["ID"]=><br />
int(1)<br />
["caps"]=><br />
array(1) {<br />
["administrator"]=><br />
bool(true)<br />
}<br />
["cap_key"]=><br />
string(25) "wp_capabilities"<br />
["roles"]=><br />
array(1) {<br />
[0]=><br />
string(13) "administrator"<br />
}<br />
["allcaps"]=><br />
array(63) {<br />
["switch_themes"]=><br />
bool(true)<br />
["edit_themes"]=><br />
bool(true)<br />
["activate_plugins"]=><br />
bool(true)<br />
["edit_plugins"]=><br />
bool(true)<br />
["edit_users"]=><br />
bool(true)<br />
["edit_files"]=><br />
bool(true)<br />
["manage_options"]=><br />
bool(true)<br />
["moderate_comments"]=><br />
bool(true)<br />
["manage_categories"]=><br />
bool(true)<br />
["manage_links"]=><br />
bool(true)<br />
["upload_files"]=><br />
bool(true)<br />
["import"]=><br />
bool(true)<br />
["unfiltered_html"]=><br />
bool(true)<br />
["edit_posts"]=><br />
bool(true)<br />
["edit_others_posts"]=><br />
bool(true)<br />
["edit_published_posts"]=><br />
bool(true)<br />
["publish_posts"]=><br />
bool(true)<br />
["edit_pages"]=><br />
bool(true)<br />
["read"]=><br />
bool(true)<br />
["level_10"]=><br />
bool(true)<br />
["level_9"]=><br />
bool(true)<br />
["level_8"]=><br />
bool(true)<br />
["level_7"]=><br />
bool(true)<br />
["level_6"]=><br />
bool(true)<br />
["level_5"]=><br />
bool(true)<br />
["level_4"]=><br />
bool(true)<br />
["level_3"]=><br />
bool(true)<br />
["level_2"]=><br />
bool(true)<br />
["level_1"]=><br />
bool(true)<br />
["level_0"]=><br />
bool(true)<br />
["edit_others_pages"]=><br />
bool(true)<br />
["edit_published_pages"]=><br />
bool(true)<br />
["publish_pages"]=><br />
bool(true)<br />
["delete_pages"]=><br />
bool(true)<br />
["delete_others_pages"]=><br />
bool(true)<br />
["delete_published_pages"]=><br />
bool(true)<br />
["delete_posts"]=><br />
bool(true)<br />
["delete_others_posts"]=><br />
bool(true)<br />
["delete_published_posts"]=><br />
bool(true)<br />
["delete_private_posts"]=><br />
bool(true)<br />
["edit_private_posts"]=><br />
bool(true)<br />
["read_private_posts"]=><br />
bool(true)<br />
["delete_private_pages"]=><br />
bool(true)<br />
["edit_private_pages"]=><br />
bool(true)<br />
["read_private_pages"]=><br />
bool(true)<br />
["delete_users"]=><br />
bool(true)<br />
["create_users"]=><br />
bool(true)<br />
["unfiltered_upload"]=><br />
bool(true)<br />
["edit_dashboard"]=><br />
bool(true)<br />
["update_plugins"]=><br />
bool(true)<br />
["delete_plugins"]=><br />
bool(true)<br />
["install_plugins"]=><br />
bool(true)<br />
["update_themes"]=><br />
bool(true)<br />
["install_themes"]=><br />
bool(true)<br />
["update_core"]=><br />
bool(true)<br />
["list_users"]=><br />
bool(true)<br />
["remove_users"]=><br />
bool(true)<br />
["add_users"]=><br />
bool(true)<br />
["promote_users"]=><br />
bool(true)<br />
["edit_theme_options"]=><br />
bool(true)<br />
["delete_themes"]=><br />
bool(true)<br />
["export"]=><br />
bool(true)<br />
["administrator"]=><br />
bool(true)<br />
}<br />
["filter"]=><br />
NULL<br />
}<br />
Skip to note 9 content
Codex
Default usage
$user = get_user_by( 'email', 'user@example.com' ); echo 'User is ' . $user->first_name . ' ' . $user->last_name;Skip to note 10 content
Joseph G.
I always prefer to check if the variable ($user) is empty or not before echoing any properties of the $user object:
$user = get_user_by( ’email’, ‘user@example.com’ );
if ( ! empty( $user ) ) {
echo ‘User is ‘ . $user->first_name . ‘ ‘ . $user->last_name;
}
This is to keep things clean and prevent error messages and warnings.
Skip to note 11 content
Jino MB
If you want to get the user id from user loginname.
$user = get_user_by('login','loginname'); if($user) { echo $user->ID; }Skip to note 12 content
destabilizator
To obtain user’s email via this, you have to use “user_email” property, not just “email”.
$user = get_user_by('login', $username);<br />if ($user) {<br />
$details['name'] = $user->first_name . ' ' . $user->last_name;<br />
$details['email'] = $user->user_email;<br />
};
Skip to note 13 content
zackcarlson
get_user_by('login', $user_login)is case sensitive. Which means
get_user_by('login', "UserName")would not match any users with like
"username"loginoremailsearch options.Skip to note 14 content
Ahmad Ali
Find user by id / email / username
$new_member_id = $_POST['new_member_id']; $u = null; if (intval($new_member_id)) $u = get_user_by('id', $new_member_id); else if (strpos($new_member_id, '@') != false) $u = get_user_by('email', $new_member_id); else $u = get_user_by('login', $new_member_id);