Hi!
I use mdmsoft/yii2-admin. I can check the current logged in user role like
Yii::$app->user->can('admin');
How to check other user has admin role? I tried
Yii::$app->user->can('admin', ['user_id' => 2]);
but not works.
Hi!
I use mdmsoft/yii2-admin. I can check the current logged in user role like
Yii::$app->user->can('admin');
How to check other user has admin role? I tried
Yii::$app->user->can('admin', ['user_id' => 2]);
but not works.
Hi @istvan0304, welcome to the forum.
Please check the API Reference of yii\rbac\ManagerInterface
(https://www.yiiframework.com/doc/api/2.0/yii-rbac-managerinterface) where you’ll find some methods that you might be interrested.
These methods can be accessed via authManager
application component. For example:
// user ID
$user_id = 1;
// The roles assigned to the user
$user_roles = Yii::$app->authManager->getRolesByUser($user_id);