how to using access roles expression

i got a problem with access rules expression.

i try like this.

array('allow', // allow admin user to perform 'admin' and 'delete' actions


        'expression'=>Yii::app->user->getState('level')== 'admin',


but not working…

how to use expression for access rule?

I’m using:


but that mean that the isAdmin function must be declared

Hi, expressions are eval’d, so

'expression'=>'Yii::app->user->getState("level")== "admin"',

i got error message when i clicked update.

You are not authorized to perform this action.

this is my code.




	'expression'=>'Yii::app->user->getState("user_biasa") == "user"',


where i must declare isAdmin function?

That means the expression is eval’d to false. (Error code 403).


[*]Have you tried [font="Courier New"]$user->param[/font] instead of [font="Courier New"]Yii::app()->user->getState(param)[/font], like this

'expression'=>'$user->user_biasa == "user"',

[*]Where do you set "user_biasa" in your app?


yes. and now what should i do for this access rules?

i need only "user_biasa" for access this action…

i set in useridentity like this


Why not you try this:

array('allow', // allow admin user to perform 'admin' and 'delete' actions


        'roles'=> array('admin')


this work…

thank you very much…

where did you set "user_biasa"?


you can write in UserIdentity