function user_load_by_mail

user_load_by_mail($mail)

Fetches a user object by email address.

Parameters

string $mail: String with the account's email address.

Return value

object|bool A fully-loaded $user object upon successful user load or FALSE if user cannot be loaded.

See also

\Drupal\user\Entity\User::loadMultiple()

File

core/modules/user/user.module, line 234
Enables the user registration and login system.

Code

function user_load_by_mail($mail) {
  $users = entity_load_multiple_by_properties('user', array('mail' => $mail));
  return $users ? reset($users) : FALSE;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!user!user.module/function/user_load_by_mail/8.1.x