function UserDataInterface::get

Same name in other branches
  1. 8.9.x core/modules/user/src/UserDataInterface.php \Drupal\user\UserDataInterface::get()
  2. 10 core/modules/user/src/UserDataInterface.php \Drupal\user\UserDataInterface::get()
  3. 11.x core/modules/user/src/UserDataInterface.php \Drupal\user\UserDataInterface::get()

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.
1 method overrides UserDataInterface::get()
UserData::get in core/modules/user/src/UserData.php
Returns data stored for a user account.

File

core/modules/user/src/UserDataInterface.php, line 32

Class

UserDataInterface
Defines the user data service interface.

Namespace

Drupal\user

Code

public function get($module, $uid = NULL, $name = NULL);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.