You are here

public function MembershipManagerInterface::getUserGroupIds in Organic groups 8

Returns all group IDs associated with the given user.

This is similar to \Drupal\og\MembershipManager::getGroupIds() but for users. The reason there is a separate method for user entities is because the storage is handled differently. For group content the relation to the group is stored on a field attached to the content entity, while user memberships are tracked in OgMembership entities.

Parameters

int $user_id: The ID of the user to get groups for.

array $states: (optional) Array with the state to return. Defaults to active.

Return value

array An associative array, keyed by group entity type, each item an array of group entity IDs.

See also

\Drupal\og\MembershipManager::getGroupIds()

1 method overrides MembershipManagerInterface::getUserGroupIds()
MembershipManager::getUserGroupIds in src/MembershipManager.php
Returns all group IDs associated with the given user.

File

src/MembershipManagerInterface.php, line 35

Class

MembershipManagerInterface
Membership manager interface.

Namespace

Drupal\og

Code

public function getUserGroupIds($user_id, array $states = [
  OgMembershipInterface::STATE_ACTIVE,
]);