WebTechKitchen; Your Web Technology Kitchen, contact us to create, or maintain your websites and other digital properties.

Instead of using node_save or user_save use entity_metadata_wrapper !

Submitted by barnettech on Wed, 05/15/2013 - 10:08

In Drupal7 with entities there are some cooler ways of manipulating entity objects than using node_save and user_save, now this code for instance will allow you to add a value to the cck machine name field "field_user_terms" which takes multiple values  -- many taxonomy terms can be assigned to this field so you'll notice it's an array:

$user = user_load($current_row->uid);
$obj = entity_metadata_wrapper('user', $user);
$obj->field_user_terms[] = $current_row->tid;
$obj->save();