Check for group member

Events happening in the community are now at Drupal community events on www.drupal.org.
hetrus's picture

Hello
On the site (drupal 7) there are the authorized users and groups (organic groups module) consisting of authorized users. There is a content type, I want to display only for group members (but not group content - so the groups could not edit it). How do I check whether a user to a group member (e.g. such as checking for anonymous <? php global $ user; if ($ user-> uid): ?> )? I do not mean checking for a specific group, and in general to an active member of any group. Thanks.

Comments

Solution?

jpshayes's picture

Did you ever figure this out. I am looking for the same.

Provided I've understood your

CrazyJoeMalloy's picture

Provided I've understood your question correctly you're probably looking for functions like og_is_member() and og_get_entity_groups()

og_get_entity_groups() returns a list of group ids that an entity belongs to and og_is_member() returns true/false is an entity is a member of a particular group id, between the two of those you should be able to get what you need.

I'm using them to make sure that the user was a member of the same group as the currently being viewed node in my module - worked like a charm for my needs.

Organic groups

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: