Filament Shield Have a Default Role
hi everyone i just wondering how to make it posible when the user register to the panel he/she can have a default role value as a user
8 Replies
Isn't it by default that when there is a new registration you automatically get Panel_user access rights?
i want to point it in another type of user role
create a observer
Hi,
You can use the boot() function in your User model:
As JustNoOne pointed out, you need an observer, when user is created check for roles, if none exist assign one.
You have to assing one to the user and not just set a global default really.
Or add the role to the user creation as normal which has the default.
If you have many roles and have a specific user role for that panel, you need to extend the Register class and assign it to your panel, then override the
register
method and add your role assignment.
And in your panel
Let me know if it works for you.Something like that:
For basic logic, this makes sense. Observers can be used for more in depth tasks