Hi,
I want to add a new user programmatically. The user should not be active, not validated and should join a specific group. Here is what I’ve done so far.
$userRegistration = Core::make('user/registration');
$user = $userRegistration->create(['uName' => $uName, 'uEmail' => $email, 'uPassword' => $password, 'uIsValidated' => false]);
$user->setUserIsActive(false);
$user->setAttribute('user_token', $token);
$group = \Group::getByName('Group Name');
if (is_object($group)) {
if (!$user->inGroup($group)) {
$user->enterGroup($group);
}
}
The user is created and not validated, what is great but the user is active and not added to the group. What am I doing wrong here?