function og_is_member in Organic groups 7.2
Same name and namespace in other branches
- 7 og.module \og_is_member()
Return TRUE if entity belongs to a group.
Parameters
$group_type: The entity type of the group.
$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 membership states to check against. If omitted then only active (OG_STATE_ACTIVE) memberships will be checked.
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::testGroupAccess in og_access/
og_access.test - Group with access field.
- OgAccessTestCase::testGroupContentAccessDefault in og_access/
og_access.test - Group with access field and group content with default definition.
- OgAccessTestCase::testGroupContentAccessNotDefault in og_access/
og_access.test - Group with access field and group content with different definition from the group.
- OgAccessTestCase::testGroupContentAccessNotExist in og_access/
og_access.test - Test group content without access field.
- OgAccessTestCase::testOgStrictPrivate in og_access/
og_access.test - Test a group content that belongs to a private and non-private group results in a private group content.
File
- ./
og.module, line 2596 - Enable users to create and manage groups with roles and permissions.
Code
function og_is_member($group_type, $gid, $entity_type = 'user', $entity = NULL, $states = array(
OG_STATE_ACTIVE,
)) {
$groups = og_get_entity_groups($entity_type, $entity, $states);
return !empty($groups[$group_type]) && in_array($gid, $groups[$group_type]);
}