Access roles

I have a problem … my application has five roles to access …

When I login I need to recognize the role of those who login and using this to show a different menu based on the initial roles …

I create a function in class UserIdentity??

Help me…

For recognize the role you can use checkAcces().

In your menu you can write something like:


if ($user->checkAccess('role1'))


in practice, you can build a different array according to your permissions.

CMenu has a ‘visible’ property that lets you determine whether a menu item will be shown. Here’s how the default generated webapp handles it for login/logout situations, you can do your visibility tests with checkAccess() as zaccaria mentioned.

<?php $this->widget('zii.widgets.CMenu',array(


		array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),

		array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)


)); ?>