public function GetServices::createNewUser in Simple Node Importer 8
2 calls to GetServices::createNewUser()
- GetServices::getUserByEmail in src/
Services/ GetServices.php - GetServices::getUserByUsername in src/
Services/ GetServices.php
File
- src/
Services/ GetServices.php, line 444
Class
Namespace
Drupal\simple_node_importer\ServicesCode
public function createNewUser(string $email = NULL, string $uname = NULL) {
if (!empty($email)) {
$today = date('dmy');
$username = explode('@', $email);
$userId = $this
->getUserByUsername($username[0]);
if ($userId && is_int($userId)) {
$uname = $username . $today;
}
else {
$uname = $username;
}
}
elseif (!empty($uname)) {
$email = '';
}
$user = User::create([
'name' => $uname,
'mail' => $email,
'pass' => user_password(10),
'status' => 1,
'roles' => [
'authenticated',
],
]);
return $user
->save();
}