Drupal: Storing data in the user profile

| drupal

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.

You can comment with Disqus or you can e-mail me at sacha@sachachua.com.