/drupal-user-data-example

An example of how to store and retrieve complex variables in the user data column.

Primary LanguagePHPApache License 2.0Apache-2.0

Drupal User data - how to store user specific content without fields

All accompanying code for the tutorial available at http://www.codesidekick.com/blog/user-data-how-store-user-specific-content-without-fields.

Usage

Set data to the user object.

global $user;
$account = entity_metadata_wrapper('user', $user);
$account->employee_number->set(60000);
entity_save('user', $account);

Get data from the user object.

global $user;
$account = entity_metadata_wrapper('user', $user);
$employee_number = $account->employee_number->value();