@harvey:
When it comes to users, you have a couple of possibilities. Yes, this information is cached, but not when doing a direct query.
This code will always get the current user:
This code will get any user you want:
$id = 1;
$user = $modx->getObject('modUser', $id);
In regard to fields, there are normal user fields and extended user fields.
A normal user field is not an array, but a value. It is also in the Profile object.
// Get the user via one of the methods above...
$profile = $user->getOne('Profile');
$email = $profile->get('email');
$value = '[email protected]';
$profile->set('email', $value);
$profile->save();
Extended Fields are an array, so you access these fields as if they were an array. This is the code to get/set extended fields.
$profile = $user->getOne('Profile)
$extended = $profile->get('extended');
// Set an extended field
$extended['field1'] = 'joe';
// Send the extended back to the Profile
$profile->set('extended', $extended);
// Save the Profile
$profile->save();
Generally, if these methods are not working, you have the wrong User object. This often happens to coincidentally be '0'. Make sure you are getting either a) the current user or b) the user via getObject(). I never happen to use array_merge, simply because it frustrates me. The DB behaves by only setting what you tell it to, so there is no need to array_merge in my experience.