Created
November 5, 2013 21:24
-
-
Save ezra-g/7326587 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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