Drupal: Storing data in the user profile

If you want to store data in the user profile, here's an example of a quick and dirty way to do it:

global $user;
if ($user) {
  $array = array('fieldname' => 'value_to_save');
  user_save($user, $array);
}

Then access it with $user->fieldname. For more configurability, check out the Profile module.

Technorati Tags:

Save to - del.icio.us - Digg it - reddit - StumbleUpon

RSS feed | Trackback URI

1 Comment »

Hello,

First of all congratulations on your blog!
You make me understand you I could load or save data in the user profile! :)

By the way… maybe you could help me:
I've recently installed Drupal 6.x and Privatemsg module but I can't see where to send msgs to users.

Thanks!

Luís

 
Name (required)
E-mail (required - never shown publicly)
Website / Blog address:
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line=""> in your comment.

Subscribe without commenting

`

On This Day...