public function SocialAuthUserManager::loadUserByProperty in Social Auth 8
Loads existing Drupal user object by given property and value.
Note that first matching user is returned. Email address and account name are unique so there can be only zero or one matching user when loading users by these properties.
Parameters
string $field: User entity field to search from.
string $value: Value to search for.
Return value
\Drupal\user\Entity\User|false Drupal user account if found False otherwise
2 calls to SocialAuthUserManager::loadUserByProperty()
- SocialAuthUserManager::authenticateUser in src/
SocialAuthUserManager.php - Creates and/or authenticates an user.
- SocialAuthUserManager::generateUniqueUsername in src/
SocialAuthUserManager.php - Ensures that Drupal usernames will be unique.
File
- src/
SocialAuthUserManager.php, line 260
Class
- SocialAuthUserManager
- Contains all logic that is related to Drupal user management.
Namespace
Drupal\social_authCode
public function loadUserByProperty($field, $value) {
$users = $this->entityTypeManager
->getStorage('user')
->loadByProperties(array(
$field => $value,
));
if (!empty($users)) {
return current($users);
}
// If user was not found, return FALSE.
return FALSE;
}