Hello,

How can i check if user is a member of a group or not?

I want to show different thing to both of them.

Thank you very much!

Comments

amitaibu’s picture

Status: Active » Fixed

og_is_member()

WEBstar’s picture

Yes...

But where do i put this?

if (og_is_member($gid)) {
  drupal_set_message('Current logged in user is member');
}
amitaibu’s picture

Feel free to look at the tests that show how to use the API.

WEBstar’s picture

Where can i find them?

Thank you!

WEBstar’s picture

I tried this one:

 $account = $user; if (og_is_member('19', 'user', $account)) 
{ print('User id 3 is member of group 12'); }
 

But not working... I get an error: Illegal offset type in og_get_entity_groups() (line 1986 ... )

balagan’s picture

I don't know what you want to show them, but maybe you can try to use the views module for this.

WEBstar’s picture

simple text..

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

alienzed’s picture

I got that too... ever figure this out?

simon_j_nichols’s picture

Issue summary: View changes

amitaibu is referring to the og.test file in the module directory. Great source of api calls

og_is_member documentation can be found here

http://www.drupalcontrib.org/api/drupal/contributions%21og%21og.module/f...

Very quick look at your example I would suggest trying og_is_member('node', '19', 'user', $account))

Bhanuji’s picture

we have a function.

og_is_member('node', $gid, 'user', $user)

Return TRUE if a user belongs to a group.

For reference please check og_is_member()

Rahulmon Johnson’s picture

How it check in group module???