Hoauth: How To Enable/fix Profile Fields To Update Upon Registration


Kinda new at this so please be detailed if you know the solution.

I have yii-user and hoauth working quite fine together (google, facebook, twitter & linkedin, all). My issue is that when the user doesn’t have an account yet and hoauth created a new account, it does not populate anything beyond the fields of “firstname” and “lastname” even though I have created all the profile fields I could identify by name in the code of the above listed providers. So I have the fields, naming matches the field names returned by the providers but nothing further than the above two (originally-there yii-user) fields gets populated.

Feels like I left a switch out or something in a config somewhere, doesn’t make sense based on my newb assessment of the code.

Can anyone help, please?

Hi, pethee

The problem is, that I have hardcoded two default yii-user profile fields (first and lastname). This two fields will be automatically saved in Profile model and all the fields, that you specified in HOAuthAction::attributes property will be applied to the User model.

Probably I need to create one more property e.g. HOAuthAction::profileAttributes where you will specify the properties for user profile. What do you think about it?

Hi SleepWalker!

Yes, I do believe I have found the First and Lastname in the code. So what you mean to say is if I extend that code and set up further fields (hard-coded) that I have such as

$profile->gender = $userProfile->gender;

(got this from HOAuthAction.php(365)) then it should work.

I do think an automatic iteration should be of course better than either the hard-coded part or even the one specifying in the controller the attribute fields. Btw, is this not what populateModel() should do? As I said, I’m not an expert but it gives me the impression that it checks if the fieldname received from the social network matches any fieldnames in the user $model and if so, it populates it. Or is this something else?

Thanks again

populateModel() works only with User model, not Profile. And it loop through all attributes, that was specified in action attributes property and save social profile field to the User model. I can write the similar thing for Profile model. But I can’t magicaly populate User model (e.g. watching for similar fields, because the fields will be not always the same. gender can be also ‘g’, ‘sex’, ‘s’ and so on).