function user_load_by_name
Same name in other branches
- 7.x modules/user/user.module \user_load_by_name()
- 8.9.x core/modules/user/user.module \user_load_by_name()
- 10 core/modules/user/user.module \user_load_by_name()
- 11.x core/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.
See also
\Drupal\user\Entity\User::loadMultiple()
9 calls 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.
- DbLogTest::doUser in core/
modules/ dblog/ tests/ src/ Functional/ DbLogTest.php - Generates and then verifies some user events.
- PathProcessor::processInbound in core/
modules/ system/ tests/ modules/ url_alter_test/ src/ PathProcessor.php - Processes the inbound path.
- PathProcessorTest::processInbound in core/
modules/ system/ tests/ modules/ url_alter_test/ src/ PathProcessorTest.php - Processes the inbound path.
- RestRegisterUserTest::registerUser in core/
modules/ hal/ tests/ src/ Functional/ user/ RestRegisterUserTest.php - Registers a user via REST resource.
File
-
core/
modules/ user/ user.module, line 194
Code
function user_load_by_name($name) {
$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.