Skip to content

Instantly share code, notes, and snippets.

@ezra-g
Created November 5, 2013 21:24
Show Gist options
  • Save ezra-g/7326587 to your computer and use it in GitHub Desktop.
Save ezra-g/7326587 to your computer and use it in GitHub Desktop.
/**
* Return TRUE if the entity is acting as a group.
*
* @param $entity_type
* The entity type.
* @param $entity
* The entity object, or the entity ID.
*/
function og_is_group($entity_type, $entity) {
$wrapper = entity_metadata_wrapper($entity_type, $entity);
$bundle = $wrapper->getBundle();
if (!field_info_instance($entity_type, OG_GROUP_FIELD, $bundle)) {
return variable_get("og_is_group__{$entity_type}__{$bundle}", FALSE);
}
return !empty($wrapper->{OG_GROUP_FIELD}) && $wrapper->{OG_GROUP_FIELD}->value();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment