Update CCK fields on a User I'm working on a Drupal 6 project and we've added some fields to a user profile via CCK. What's the best way to update this information programmatically? When the user logs in I'm gathering some data from a 3rd party API that I need to update their user with. I've got the data, but the global $user object doesn't seem to have the extra fields.
OK, the information is stored in the node associated with the user, and not the user itself.

You essentially need to query the database to find the node for the user, load it, edit the fields, and then save out the node.

It would roughly look  like

$sql = "
  SELECT nid FROM {node}
  WHERE type = '%s' AND uid = %d AND status = %d
";

$nid = (int) db_result(db_query($sql, "profile", $user-&gt;uid, 1));

$node = node_load($nid);

$node-&gt;field_foo[0]["value"] = "foo";

node_save($node);


This is a copy/edit/paste from a project of mine, so error checking and other steps have been omitted, and the code may not run as-is.