interface UserDataInterface (View source)

Defines the user data service interface.

Methods

mixed|array
get(string $module, int $uid = NULL, string $name = NULL)

Returns data stored for a user account.

set(string $module, int $uid, string $name, mixed $value)

Stores data for a user account.

delete(string|array $module = NULL, int|array $uid = NULL, string $name = NULL)

Deletes data stored for a user account.

Details

mixed|array get(string $module, int $uid = NULL, string $name = NULL)

Returns data stored for a user account.

Parameters

string $module

The name of the module the data is associated with.

int $uid

(optional) The user account ID the data is associated with.

string $name

(optional) The name of the data key.

Return Value

mixed|array

The requested user account data, depending on the arguments passed:

  • For $module, $name, and $uid, the stored value is returned, or NULL if no value was found.
  • For $module and $uid, an associative array is returned that contains the stored data name/value pairs.
  • For $module and $name, an associative array is returned whose keys are user IDs and whose values contain the stored values.
  • For $module only, an associative array is returned that contains all existing data for $module in all user accounts, keyed first by user ID and $name second.

set(string $module, int $uid, string $name, mixed $value)

Stores data for a user account.

Parameters

string $module

The name of the module the data is associated with.

int $uid

The user account ID the data is associated with.

string $name

The name of the data key.

mixed $value

The value to store. Non-scalar values are serialized automatically.

delete(string|array $module = NULL, int|array $uid = NULL, string $name = NULL)

Deletes data stored for a user account.

Parameters

string|array $module

(optional) The name of the module the data is associated with. Can also be an array to delete the data of multiple modules.

int|array $uid

(optional) The user account ID the data is associated with. If omitted, all data for $module is deleted. Can also be an array of IDs to delete the data of multiple user accounts.

string $name

(optional) The name of the data key. If omitted, all data associated with $module and $uid is deleted.