public function UserManager::createNewUser in Social Auth 8.2
Same name and namespace in other branches
- 3.x src/User/UserManager.php \Drupal\social_auth\User\UserManager::createNewUser()
Creates a new user.
Parameters
\Drupal\social_auth\User\SocialAuthUserInterface $user: The data of the user to be created.
Return value
\Drupal\user\UserInterface|null The Drupal user if successful Null otherwise.
File
- src/
User/ UserManager.php, line 131
Class
- UserManager
- Manages database related tasks.
Namespace
Drupal\social_auth\UserCode
public function createNewUser(SocialAuthUserInterface $user) {
// Download profile picture for the newly created user.
if ($user
->getPictureUrl()) {
$this
->setProfilePic($user);
}
$drupal_user = $this
->createUser($user);
if ($drupal_user) {
// If the new user could be registered.
$this
->addUserRecord($drupal_user
->id(), $user
->getProviderId(), $user
->getToken(), $user
->getAdditionalData());
if ($this
->saveUser($drupal_user)) {
return $drupal_user;
}
}
return NULL;
}