You are here

public function SimpleFbConnectUserManager::loadUserByProperty in Simple FB Connect 8.2

Same name and namespace in other branches
  1. 8.3 src/SimpleFbConnectUserManager.php \Drupal\simple_fb_connect\SimpleFbConnectUserManager::loadUserByProperty()

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 ore 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

1 call to SimpleFbConnectUserManager::loadUserByProperty()
SimpleFbConnectUserManager::generateUniqueUsername in src/SimpleFbConnectUserManager.php
Ensures that Drupal usernames will be unique.

File

src/SimpleFbConnectUserManager.php, line 68
Contains \Drupal\simple_fb_connect\SimpleFbConnectUserManager.

Class

SimpleFbConnectUserManager
Contains all logic that is related to Drupal user management.

Namespace

Drupal\simple_fb_connect

Code

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;
}