How to access to a custom field in "User" table,to check access?

Hello all,

I have an urgent case t solve. In "User" table i have a field "is_admin".

How do i properly check if it's set to 1 or 0? In templates, and in controllers?

Or am i doing it wrong? Anyway i need a way to see if logged in user can do some extra stuff, like go to admin panel.

Please, HELP

ok so now my problem has split onto two questions :)

first of, i used

$auth = Yii::app()->authManager;

		$role = $auth->createRole('admin');

to create admin role, and now i will try to figure out how to use that manager.

But any way i need to know how to access custom "User" table fields/ Are they being stored in user object somewhere, or i need to get in from database using one extra query?

I added an operation:

array('accessManager', 'Access manager panel'),

and i also have a role 'admin'

i assigned user id#1 to role 'admin', but how do i assign 'accessManager' operation to that user? or to that role? And most important, how do i check if it's there?

what should i put in template to see if curret user can do 'accessManager' operation? How do i check in template that this user is in admin role?

If you are using a single field to indicate the access level, you don't need to use auth manager, which is typically used for more complex access controls.

In order to access the table column 'is_admin' via Yii::app()->user, you will need to extend CWebUser and define a property like the following:

public function getIsAdmin()


      return User::model()->findByPk($this->id)->is_admin;



Could you please give me a hint, which class should i extend and which method should i rewrite, so that every time a User data is being retrieved from database, it also gets some extra data for that user, from another table, and gives me access to it.

also, it would be nice if I could do all this everywhere BUT during authorization

Ok, I got how to extend it… and this was pretty easy, because all i had to do is to add one line to my config


			// enable cookie-based authentication




Maybe it will be useful fo someone. The rest is easy

TCWebUser is your Controller?