[drupal-devel] Storing arbitrary data for a user

Dan Robinson dan at civicactions.com
Sun Feb 20 06:13:28 UTC 2005


ok - I'm almost there....

Everything is working - except i'm working in a callback specified in
<mymodule>_menu -

function forummail_menu($may_cache) {
  global $user;

  $items = array();

  if ($may_cache) {
        $items[] = array('path' => "user/$user->uid/forummail", 'title'
=> t('my forum mail settings'),'callback' => forummail_page, 'type' =>
MENU_LOCAL_TASK);
  }

  return $items;
}


this sets up a "tab" in the user/2/forummail.  So now I have a form and
everything is working - however I'm not hooking 'form' or 'validate' so
it is not saving the user.  I've tried to manually call user_save - but
it doesn't like that very much.  Here is the code I'm trying to execute -

function forummail_page() {
..snip..

      if ($edit['saved']) {      // we're back from a save form event
          $user->forummail_mode = $edit['mode'];
          // save off the data here!!
      }

..snip..

}

Thanks,

Dan

> Dan - all you need to do is set $user with new properties during 
> hook_user('form') or hook_user('validate'). They will be saved 
> automatically by user.module. So if you want to set a gender, just do 
> this
>
> global $user;
> $user->gender = 'female';
>
>




More information about the drupal-devel mailing list