Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ayekoto's avatar

same login interface, how do i redirect when user have multiple roles ?advice needed

i have a custom login interface which log users in base on roles, and redirect them but now i want to implement multiple users having multi roles, so the question is how do i redirect when this users has multi roles from same login interface that redirects base on roles

0 likes
2 replies
Demers94's avatar

You could do something like this :

if($user->hasRole('admin')) return redirect('/admin');
    elseif($user->hasRole('manager')) return redirect('/manage');
    else return redirect('/');

The actual implementation will depend on how your code is structured, but basically you iterate through the different options. Just place them in order of which matters the most (ie: you might want a user who is both admin and regular user to be redirected to the admin dashboard, so make that check first).

ayekoto's avatar

Note a user this time around will have admin & manager role....

Please or to participate in this conversation.