Updating profile fields via user.save

Events happening in the community are now at Drupal community events on www.drupal.org.
barnettech's picture

So if I create a new user via xmlrpc and the services module I can populate profile fields no problem using user.save, but for some reason I cannot update profile fields using user.save I'm actually connecting to xmlrpc from java.

I've done it in php as well.

$user_object = array(
'name' => 'test_user_from_api',
'profile_name' => 'James',
'profile_last_name' => 'Test',
'pass' => 'testuser',
'mail' => 'james@yahoo.com',
'status' => 1
);

if I pass this user_object to user.save it will create a new user, but after if I specify the user's uid so it tells it to do an update of this user's record, it will update everything successfully (if I make some changes) except for the profile_last_name and profile_name fields (which are the user's last name and first name respectively).

Anybody already run into this? If a Woman changes her last name (as a for instance) after getting married, I cannot do updates to the profile field for her lastname to be updated. Before I start coding my own version of user.save I want to see if anyone has encountered this already.

Thanks

Comments

attach the profile fields

doublejosh's picture

Believe you need to attach the profile fields to the user object with a call to profile_load_profile(&$user);

There is also this http://api.drupal.org/api/drupal/modules--profile--profile.module/functi...

User update is done by profile category

waldmanm's picture

When user.save updates an existing user it "executes" (using drupal_execute) the form 'user_profile_form'. This saves only one category of profile fields, which you need to set in the 'category' property of the user object you send in. This is in addition to setting the profile fields themselves in the user object, of course.

If you have multiple categories, you'll need to call user.save multiple times.

If you don't set the 'category' field, user.save sets it to the default 'account' (for saving core user data.)

The reason creating a user works fine is that user.save uses a different form ('user_register') for that.

Micah

Services

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week