User plugin automatic activation not working

Even though the setting of Activation mode is set to automatic, after the admin creates a user, the warning box appears with the message: “User not activated! This user has not been activated and may be unable to sign in. Activate this user manually.”
I guess if the activation mode is set to automatic, the created users should be automatically activated. Am I wrong?
Using OC. 3.4.16

I agree, I feel like it should.

Just tested, registering from /rainlab/user/users/create and even with activate_mode set to auto, the user was not activated.

I guess it works from the frontend component.

For now, perhaps you can add in your boot function in Plugin.php:

\Event::listen('rainlab.user.register', function($user) {
    if (RainLab\User\Models\Settings::get('activate_mode') == RainLab\User\Models\Settings::ACTIVATE_AUTO) {
         $user->is_activated = 1;
         $user->save();
    }
});

Hi, thanks. But for some reason it’s not working. Looks like the event is not firing… I’ve tested all the steps in that callback function in tinker and it’s ok. but it doesn’t activate the user. No errors.

right : onRegister() that fire rainlab.user.register is in the component.

So for now, you could this:

\RainLab\User\Models\User::extend(function ($model) {

            $model->bindEvent('model.beforeCreate', function () use ($model) {
                if (\RainLab\User\Models\Settings::get('activate_mode') == \RainLab\User\Models\Settings::ACTIVATE_AUTO) {
                    $model->is_activated = 1;
                }
            });
}
1 Like