Back to Passage Permission and Roles System Support

corymillz40435183
corymillz40435183

This might seems a little bit off but i have been trying to wrap my head around permission, roles and groups. I am new to octobercms and learning by practice and i find your plugin easy to grasp. I have two groups and two registration forms meant for these two groups, One for sellers and the other for buyers. I want users to be automatically added to groups on registration. I little digging around and i learnt i should create a new plugin and add this in the boot method

use Rainlab\User\Models\UserGroup 
use Event;

    public function boot()
{

Event::listen('rainlab.user.register', function($user){
    $group = 
    UserGroup::where('code', 'seller-account')->first();

    $user->groups()->add($groups);
    $user->save();
});

Event::listen('rainlab.user.register', function($user){
    $group = 
    UserGroup::where('code', 'buyer-account')->first();

    $user->groups()->add($groups);
    $user->save();
});

}

That doesn't seem to do anything and i dont know how it connect to the forms. If you have had to deal with something similar. I will really appreciate your help on this.

Last updated

Kurt Jensen
Kurt Jensen

Try changing:

 $user->groups()->add($groups); 

to

 $user->groups()->add($group); // no s

1-2 of 2