visible menu

I am trying to make parts of menu conditional to user authorisation status. I have the following code in ‘protected/views/layouts/main.php’ -

			array('label'=>'Management', 'items'=>array(

			array('label'=>'User Management', 'url'=>array('/user')),

			array('label'=>'Status Report', 'url'=>array('/casesheet/update')),

				), 'visible'=>!Yii::app()->user->isUserAdmin),

I have initialised the variable in UserIdentity.php thus -



But when I run the program I get the following error.




[color="maroon"][font="Verdana"][size="2"]Property "CWebUser.isUserAdmin" is not defined.[/size][/font][/color]

Source File


[font="Verdana"] [/font]

[font=“Verdana”][size=“2”]I persume the problem is in initialisation as the menu works with ‘isGuest’ in place of ‘isUserAdmin’. So how do I set ‘isUserAdmin’ parameter in [color="#800000"]CWebUser at the very start?[/color][/size][/font]


you must extend cwebuser class and add a method to check if the user is admin, or a property like you did

to extend cwebuser check out this link

Thanks @Gustavo. It works!!