How to get user role in Yii2?

b24 picture b24 · Aug 11, 2014 · Viewed 38.4k times · Source

How to get user role in Yii2?

I searched and read Yii2 guide but I didn't find any solution.

Answer

Manquer picture Manquer · Aug 11, 2014

You can get Roles for an user by using getRolesByUser function

You can use it like this

\Yii::$app->authManager->getRolesByUser($user_id);