Skip to content

Instantly share code, notes, and snippets.

@maximishchenko
Created March 13, 2016 09:06
Show Gist options
  • Select an option

  • Save maximishchenko/2936edb1983d7e4300cd to your computer and use it in GitHub Desktop.

Select an option

Save maximishchenko/2936edb1983d7e4300cd to your computer and use it in GitHub Desktop.
Yii2 Checking Users Role
<?php
if (Yii::$app->user->can('root')) {
echo 'Hello, Root!';
}
elseif (Yii::$app->user->can('admin')) {
echo 'Hello, Admin!';
}
elseif (Yii::$app->user->can('head')) {
echo 'Hello, Head!';
}
elseif (Yii::$app->user->can('manager')) {
echo 'Hello, Manager!';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment