yii-user - How do I get profile data?

I must be missing something - I can’t seem to figure out how I get a user’s profile data. Someone else posted this same question on the extension page and there was no answer.


This is what I use:


If there’s anything less clunky, I’d like to know. :)

Yeah… write a shortcut

public function getUserProfile(){

return Yii::app()->getModule(‘user’)->user()->profile;



+1 ;)

So, three years later you do not need to use the "getAttribute" part.

You can access all Profile Fields directly.


BUT: I it does not work to save a new value this way.

Did anybody succeed in this?

I tried this without success:

$profile = Yii::app()->getModule('user')->user()->profile;

$profile->lastname = "2Amigos";


Any idea why this is not saving? It does not throw any error…

ok. getting closer.

None of the Fields of the model Profile is ‘safe’.

This is the problem…

Just tried to add it for one field, but then it throws this:

Property "CRequiredValidator.0" is not defined.

No, I have to step back from what I wrote above. All (except ID) fields are safe by default.

So the Save() should work out of the box.

I dont get it.

Can anybody give me a hint ?