Conditionally Display Menu Item

Hi All,

I would appreciate if someone would show me the way to conditionally display a menu item depending on

the logged in users role? For example if the user is logged in as a regular user I do not want them to even see the

"manage members" menu link. Thanks in advance for your help. BTW I am new to Yii and it is really great!!


It can easily be done using ‘visible’ property and by defining roles in your controller. For example I don’t want normal authenticated users to see ‘List Users’ link only admin is allowed so I can have following

array('label'=>'List Users', 'icon'=>'list', 'url'=>array('/user/index'), 'visible'=>Yii::app()->user->checkAccess('admin')),


Further in controller I have


'actions'=>array('create', 'index'), 


Here admin is role not username.

Thanks a million!! I will try that!