Adding a User Programmatically

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?

I think I was a little confused about the user and the userInfo object. Now it works perfectly.

    $userRegistration = Core::make('user/registration');
    				
    $userInfo = $userRegistration->create(['uName' => $uName, 'uEmail' => $email, 'uPassword' => $password, 'uIsValidated' => false]);
    $userInfo->setAttribute('user_token', $token);      			
    $userInfo->deactivate();

    $user = $userInfo->getUserObject();    				
     	
    $group = \Group::getByName('Group Name');
    if (is_object($group)) {
        if (!$user->inGroup($group)) {
    	    $user->enterGroup($group);
    	}
    }