[support] Add some info to $user

Earnie Boyd earnie at users.sourceforge.net
Wed Mar 5 17:12:13 UTC 2008


Quoting Davide Michel 'ZioBudda' Morelli <michel at ziobudda.net>:

> Hi all. I need to add some infos to $user variable. I have thinked that
> hook_user() is my "hook" :)
>
> So I have write a function that add the infos to the $account:
>
> function mw_livelloUtenti_user($op, &$edit, &$account, $category = NULL) {
>    switch ($op) {
>        case "login" :
>        case "load" :
>            if ($account->uid != NULL || $account->uid != 0) {
>
>                $tmp = db_query("SELECT mw.* FROM mw_lU AS mw LEFT JOIN
> mw_lU_user AS mwu ON mw.luid = mwu.luid WHERE mwu.uid = %d",$account->uid);
>                $account->level = db_fetch_array($tmp);
>                //print_r($account); //Ok, data are inserted (fields:
> level, data1, data2)
>            }
>            break;
>  }
> }
>
>
> Now, why when one of my other module try to access to $user->account
> this field is NULL ?
> Plz help me.
>

The user information is stored in a global $user and is also stored in 
the session.  If you don't save your additional data in the session 
then that is likely the reason your "other module" doesn't see the 
data; especially if the other module references the data with a new 
page view.

Earnie -- http://for-my-kids.com/
-- http://give-me-an-offer.com/



More information about the support mailing list