You are here

function og_is_member in Organic groups 7

Same name and namespace in other branches
  1. 7.2 og.module \og_is_member()

Return TRUE if entity belongs to a group.

Parameters

$gid: The group ID.

$entity_type: The entity type.

$entity: The entity object. If empty the current user will be used.

$states: Optional; Array with the state to return. If empty groups of all state will return.

Return value

TRUE if the entity (e.g. the user) belongs to a group and is not pending or blocked.

23 calls to og_is_member()
OgAccessTestCase::testOgAccess in og_access/og_access.test
Group with access field .
OgAccessTestCase::testOgContentAccessDefault in og_access/og_access.test
Group with access field and group content with default definition.
OgAccessTestCase::testOgContentAccessNotDefault in og_access/og_access.test
Group with access field and group content with different definition from the group.
OgAccessTestCase::testOgStrictPrivate in og_access/og_access.test
Test "Strict private" variable enabled or disabled.
OgFieldAccessTestCase::testOgFieldAccess in og_field_access/og_field_access.test
Group with access field.

... See full list

File

./og.module, line 2143
Enable users to create and manage groups with roles and permissions.

Code

function og_is_member($gid, $entity_type = 'user', $entity = NULL, $states = array(
  OG_STATE_ACTIVE,
)) {
  if ($entity_type == 'user' && empty($entity)) {
    global $user;
    $entity = clone $user;
  }
  $entity = og_load_entity($entity_type, $entity);
  $groups = og_get_entity_groups($entity_type, $entity, $states);
  return in_array($gid, $groups);
}