I have a Drupal 6 module that implements hook_user() to add a custom property on op='load';
mymodule_user($op, &$edit, &$account, $category = NULL) {
$account->external_id = mymodule_get_user_external_id($account->uid);
}
In modules, I access the global $user object. What I find is sometimes it has my ->external_id property, and sometimes it doesn't.
As a result, I end up having to check to see if my custom property is set, and if not, call user_load()
if(isset($GLOBALS['user']->external_id)) {
$account = $GLOBALS['user'];
} else {
$account = user_load($GLOBALS['user']->uid);
}
Yuck! Is this a known problem, or does it sound like I'm doing something wrong?