Skip to content

Instantly share code, notes, and snippets.

@ezra-g
Created November 5, 2013 21:24
Show Gist options
  • Select an option

  • Save ezra-g/7326587 to your computer and use it in GitHub Desktop.

Select an option

Save ezra-g/7326587 to your computer and use it in GitHub Desktop.

Revisions

  1. ezra-g created this gist Nov 5, 2013.
    18 changes: 18 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@

    /**
    * 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();
    }