function user_load_by_name
Same name and namespace in other branches
- 11.x core/modules/user/user.module \user_load_by_name()
- 10 core/modules/user/user.module \user_load_by_name()
- 9 core/modules/user/user.module \user_load_by_name()
- 8.9.x core/modules/user/user.module \user_load_by_name()
- 7.x modules/user/user.module \user_load_by_name()
Fetches a user object by account name.
Parameters
string $name: String with the account's user name.
Return value
\Drupal\user\UserInterface|false A fully-loaded $user object upon successful user load or FALSE if user cannot be loaded.
Deprecated
in drupal:11.4.0 and is removed from drupal:13.0.0. Use \Drupal::entityTypeManager()->getStorage('user')->loadByProperties() instead.
See also
https://www.drupal.org/node/3555936
1 call to user_load_by_name()
- ContactPersonalTest::checkContactAccess in core/
modules/ contact/ tests/ src/ Functional/ ContactPersonalTest.php - Creates a user and then checks contact form access.
File
-
core/
modules/ user/ user.module, line 68
Code
function user_load_by_name($name) {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use entityTypeManager()->getStorage("user")->loadByProperties() instead. See https://www.drupal.org/node/3555936', E_USER_DEPRECATED);
$users = \Drupal::entityTypeManager()->getStorage('user')
->loadByProperties([
'name' => $name,
]);
return $users ? reset($users) : FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.