user_load_by_name($name)
Fetches a user object by account name.
Parameters
string $name: String with the account's user name.
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 251
- Enables the user registration and login system.
Code
function user_load_by_name($name) { $users = \Drupal::entityTypeManager()->getStorage('user') ->loadByProperties(['name' => $name]); return $users ? reset($users) : FALSE; }
Please login to continue.