How to connect Yii: app () -> user with the User model. For example, to get an instance of the User model, call the following method:

Yii:app()->user->getUser() 

For example, I want to receive an authorized user E-mail:

 Yii:app()->user->getUser()-email; 

Some material is taken from: http://www.yiiframework.com/wiki/80/add-information-to-yii-app-user-by-extending-cwebuser-better-version/

    2 answers 2

    You can, in your UserIdentity, after successfully verifying the password, set all user data:

     foreach($user as $k => $v) { $this->setState($k, $v); } 

    After that, all fields are available by:

     Yii::app()->user->email 

      The issue is resolved. We need to set the required field in the UserIdentity:

       $this->setState('email',$this->email); 

      And then it is easy to get through:

       Yii::app()->user->getState('email'); 
      • one
        A little tediousness: You can simply access the data Yii :: app () -> user-> email; - dekameron