Hello,

I'm looking for some way to change (in DB) users profile fields from a module just knowing the field name (e.g. 'profile_realname'). Is there any profile function that makes easy to do this? Or do I have to make a complex DB query to extract 'fid' and then update 'profile_values'?

profile_save_profile() looks good, but I would like to not to worry about 'category' of the field.

Has anyone done something like this?

Comments

mrtoner’s picture

Good question! I'm looking to do this myself. I first saw user_save() which appears to be better documented than profile_save_profile(), but I am a bit nervous trying either.

adobo’s picture

Great! That did the trick, at least on Drupal 6 :)

Thank you very much!

mrtoner’s picture

So I guess you're not having a problem with the "Page Not Found" issue I had (see previous link)? (Drupal 5.7)

adobo’s picture

No, I'm not experiencing any errors.

That error looks strange, have you tried your module on a testing site with most modules disabled? Maybe some module is in conflict with yours.

mrtoner’s picture

I may give that a try -- I suspected the same thing. Meanwhile, I decided to re-write it just a little bit and use the "submit" operation instead of "after_update." Now it's working without an error; it's just that it seems a somewhat more appropriate to change the profile field after everything else is done.

youplatform’s picture

I was running into the same problem and this fixed it up right away.