Check role

Hi i am testing is some user has some role like this:

(example:tet if the user with the id=2 has the role admin)


But for any value for the second parameter(user id) the test variable is always true

I’ve never used this method, but it says in the documentation that the second argument needs to be an array:

So maybe it has to be something like:

 $test=Yii::app()->user->checkAccess('Admin', array('user_id' => 2));

No.It returns always true



current user? I mean … maybe


always return true and second parameters could be used with another kind of call of checkAccess. So, it return true also when you are not logged in as Admin?

I assume you’re looking for this:

Yii::app()->authManager->checkAccess($roleName, $userId)

We can check permission or role of user by




thank you it worked

Role Based Access Control (RBAC) with Yii Framework