[drupal-devel] Storing arbitrary data for a user
dan at civicactions.com
Sat Feb 19 08:58:12 UTC 2005
Steven Wittens wrote:
> Mark wrote:
>> Dan Robinson wrote:
>>> I have a small amount of persistant data I would like to associate
>>> with a user and would like to avoid creating a new table to store it
>>> in. I have come across variable_get and variable_set - which is
>>> great - but probably not appropriate for what I'm doing. I've also
>>> seen user->categories, but can't find any doco or info on what this is.
>> Try the $user->data array. You should be able to insert your user
>> data there.
>> To see what's currently stored there (as serialized data):
>> select uid, name, data from users;
> Custom $user fields will already be saved without modifying ->data
> directly. In fact, custom fields that do not go into data need to be
> unset explicitly in hook_user('save') to prevent this.
I'm kind of getting this, but not quite. How do I declare a customer
$user field? I'm already using the hook_user stuff so I know "when" to
do it, but I still don't know where to put this data.
More information about the drupal-devel