yii-user admin fields


How can I change yii-user to allow admin to see hidden fields?

I want fields added to the user that only admins can modify the values.


can you describe clearly what exactly you want!!!


I want to add a hidden field and allow only admins to change the value.


I want to add a field called PriceLevel that is hidden and assign values based on different users.

why you not try that field on page ( that only admin can access ) and change value , on that page no need to use hidden field , as you use that field as hidden for normal user.

if this can’t help, please more specify about your requirment.

I do not want the user to be able to see it.

Also, I am getting sql error because the birthdate field is blank.


CDbCommand failed to execute the SQL statement: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '' for column 'birthday' at row 1. The SQL statement executed was: INSERT INTO `tbl_profiles` (`lastname`, `firstname`, `birthday`, `company`, `phone`, `PriceLevel`, `user_id`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6) 

yes as you use this field as hidden , user can’t see it ,

but use same field for admin as admin can update it simple …

and can’t judge what kind of sql error you got , cause you not specifying things clearly.

and please check values post successfully, you said date is null … please use $_POST($[Model]) or $_POST($[Model][‘date’]).

Any field I mark hidden, when I bring up the record to edit as an admin, the field is not shown.

The sql error I am getting is because I have bi value in the Birthdate. If I enter a value, it works.


just can’t understand what you want to do. <_<

On the Manage Profile screen under visible.

Choices are For All, Registered Users, Only Owner, Hidden.

If I create a field and assign it Hidden, the admin cannot see this field when he edits a users profile.

I want the admin to be able to edit this field, as the user must not see this.




The user must not be able to control the PriceLevel.

This is in the yii-user extension

The only thing I can see to do is create my own model and crud code against these tables.

for this you have to use user role , if user is admin you can make field as textField or else and if user is normal user you can use field as hidden ,

just code to check the user role and define input element … simple.

Do you have an example?

I am not familiar with using user role in yii-user.


This seems to work.


public function scopes()


        return array(


















                'condition'=>'required='.self::REQUIRED_NO_SHOW_REG.' OR required='.self::REQUIRED_YES_SHOW_REG,









	public function getFields() {

		// Add Next line

	if(UserModule::isAdmin()) {


			return $this->_model;


		// Add End

		if ($this->regMode) {

			if (!$this->_modelReg)


			return $this->_modelReg;

		} else {

			if (!$this->_model)


			return $this->_model;