公告
财富商城
积分规则
提问
发文
2020-02-25 08:12发布
倾城 Initia
How to get user role in Yii2?
I searched and read Yii2 guide but I didn't find any solution.
I use :
if (\Yii::$app->authManager-> getAssignment($role,$rule_id))
for filtering user id and role in rbac, More details on Yii2 Documentation
user id
role
You can get role of the user by using createcommand.
$roleModel = Yii::$app->db ->createCommand("Select * from auth_assignment where user_id='889'") ->queryOne(); echo $roleModel['item_name'];
This will you user's role in auth assignment. Now you can check that if user is admin or editor or member.
最多设置5个标签!
I use :
for filtering
user id
androle
in rbac, More details on Yii2 DocumentationYou can get role of the user by using createcommand.
This will you user's role in auth assignment. Now you can check that if user is admin or editor or member.