I have read this post fast saving single field value about how to use field_attach_update to save nodes without the overhead of node_save().
I would like to use this for users (which it should work for, as per https://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/function/field_attach_update/7) . However, I'm not sure how to apply the examples to users.
Currently, this is my code:
if (isset($uid)) {
$user = user_load($uid);
$user_og_groups = $user->og_user_node[LANGUAGE_NONE];
$user_committee_positions = $user->field_committee_position_serno[LANGUAGE_NONE];
$user_data = my_module_import_user($cust_info, $cust_attributes, $drupal_countries, $employers);
$user = user_save($user, $user_data);
}
The $user_data variable is an array of data, which is what user_save expects (https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_save/7). user_save()
doesn't work exactly the same as node_save()
and doesn't accept a user object.
How then can I use field_attach_update to programmatically update users?