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 view 1 comment or e-mail me at sacha@sachachua.com.

1 comment

This works in one way but views module doesn't show the profile values stored in this manner. I guess this is because the data is stored in serialized manner an not in database profile table