You are here

public function MembershipManagerInterface::getUserGroups in Organic groups 8

Returns all groups associated with the given user.

This is similar to \Drupal\og\Og::getGroups() 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.

string[] $states: (optional) Array with the states to return. Defaults to active.

Return value

\Drupal\Core\Entity\ContentEntityInterface[][] An associative array, keyed by group entity type, each item an array of group entities.

See also

\Drupal\og\MembershipManager::getGroups()

\Drupal\og\MembershipManager::getMemberships()

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

File

src/MembershipManagerInterface.php, line 58

Class

MembershipManagerInterface
Membership manager interface.

Namespace

Drupal\og

Code

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