function user_load_by_mail
Same name in other branches
- 7.x modules/user/user.module \user_load_by_mail()
- 8.9.x core/modules/user/user.module \user_load_by_mail()
- 10 core/modules/user/user.module \user_load_by_mail()
- 11.x core/modules/user/user.module \user_load_by_mail()
Fetches a user object by email address.
Parameters
string $mail: String with the account's email address.
Return value
\Drupal\user\UserInterface|false A fully-loaded $user object upon successful user load or FALSE if user cannot be loaded.
See also
\Drupal\user\Entity\User::loadMultiple()
1 call to user_load_by_mail()
- _update_cron_notify in core/
modules/ update/ update.fetch.inc - Performs any notifications that should be done once cron fetches new data.
File
-
core/
modules/ user/ user.module, line 176
Code
function user_load_by_mail($mail) {
$users = \Drupal::entityTypeManager()->getStorage('user')
->loadByProperties([
'mail' => $mail,
]);
return $users ? reset($users) : FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.