I am using OG7(Organic Groups) module drupal 7 for creating groups..
In that I have added users to particular group and created a role to create content in that group i.e. Group owner
Then I need to show group members list in a individual group.
Please suggest me to display this block.

Comments

meba’s picture

Hey Ramesh, did you check the Blocks configuration? There should be a "Group members" block. There is also a page listing all members, see for example: http://groups.drupal.org/og/users/223/faces

rameshbabu.g’s picture

Thanks for your reply..But the given link displaying no results..It is displaying "Access Denined" message.Can you please tell me any other option to display group members list.

alylson’s picture

I can't see this.

samlj’s picture

I don't know how to do the same thing. I'm new to Drupal

Saoirse1916’s picture

I'm not sure if you're running into the same problem that I was, but if your groups have URLs like http://www.yoursite.com/groups/groupname (or just yoursite.com/groupname, for that matter) your problem is that the blocks system can't directly translate your URL alias to the gid (group ID) that it needs for the filter. So here's what I did, hopefully this can help you or someone else with the same problem:

1. Edit the view at /admin/structure/views, click Edit next to the og_members view.
2. Click on (group membership) OG membership: Group gid under Contextual Filters.
3. Under When the filter value is not available check the Provide default value option.
4. Select PHP Code for the type and enter the following for the code:
return arg(1);
5. Substitute 1 for whichever argument contains the group name which can be translated to gid -- in my case, my groups are all aliased as /group/groupname, so arg(0) would be group, arg(1) would be groupname which is what I want.
6. Save, and test.

If you don't have PHP Code as an option in step #4 ensure that the filter is enabled both in Modules and in Configuration/Text Formats.

illepic’s picture

For steps 3 and 4, try "Current OG group from context" instead. That works great for me.

Saoirse1916’s picture

Right on -- works great and seems less ghetto and hacky than my solution!

MrPeanut’s picture

Great! That worked! Thank you so much Saoirse1916 and illepic. I spent way too much time trying to figure that out on my own.

I then had to do the same thing with the content block.

Energyblazar’s picture

worked like charm... thanks guys.... :D

markmark’s picture

Thanks a lot Energyblazar .
Dreams are come true.

Although this is not a relevant topic under this threads.

BTW, When i am going to access the link, every time i see the message" Access is denied"

I want to get rid off it.

Powergird’s picture

Thank you very much

coderider’s picture

this is only works for OG group nodes not working at OG content pages.
one working and tested solution is below

1. Edit the view at /admin/structure/views, click Edit next to the og_members view.
2. add a Relationships OG membership: OG membership from User

3. Click on (group membership) OG membership: Group gid under Contextual Filters. and use step 2 Relationships
4. Under When the filter value is not available check the Provide default value option.
5. Select PHP Code for the type and enter the following for the code:

if(arg(1)){
  $node = node_load(arg(1));
  // check if current node is from group type
  if($node->type == 'your group type'){
    return arg(1);
  }
  // in second condition check for all your group content type like in my case below
  else if( $node->type == "doc" || $node->type == 'folder' || $node->type == 'canvas'){
    // then get Groups audience field value from group content node
    // it should return group id as we need
    return $node->og_group_ref['und'][0]['target_id']; 
  }
  else {
    return null;
  }
}else{
  return null;
}

6. Save, and test.

solution 2
In views OG create a view by name " OG members (User)"
1. Just clone this block and set name etc.
2. click Contextual Filters which already add and change value Under When the filter value is not available
Select PHP Code for the type and enter the following for the code

if(arg(1)){
  $node = node_load(arg(1));
  // check if current node is from group type
  if($node->type == 'your group type'){
    return arg(1);
  }
  // in second condition check for all your group content type like in my case below
  else if( $node->type == "doc" || $node->type == 'folder' || $node->type == 'canvas'){
    // then get Groups audience field value from group content node
    // it should return group id as we need
    return $node->og_group_ref['und'][0]['target_id']; 
  }
  else {
    return null;
  }
}else{
  return null;
}

3. save

and its done

swamiman’s picture

I'm trying to create/alter a view that will provide the names and contact info of members of groups that the current user belongs to. Is there anyway to get the group list to work with the user context instead of the node/group context?

Anonymous’s picture

"For steps 3 and 4, try "Current OG group from context" instead. That works great for me."

Special thanks to illepic.

I completely forgot to add that default setup and was going nuts trying to get this view to function. Thanks for taking the time to post, saved me a ton of hassle!

aprice42’s picture

This seems to have changed slightly since the most recent comment.

"Current OG group from context" was not available for me, so I used "Content ID from URL" under the "Provide Default Argument" option and that worked for me. So the new steps that worked for me are as follows:

  1. Edit the view at /admin/structure/views, click Edit next to the og_members view.
  2. Click on (group membership) OG membership: Group gid under Contextual Filters.
  3. Under When the filter value is not available check the Provide default value option.
  4. Select "Content ID from URL"
  5. Save

I hope this can help someone, I spent a good bit of time working this out.

dchalmer’s picture

if "Current OG group from context" is not available for you - enable the "Organic groups context" sub-module.

Should then be able to choose "Current OG group from context" in the contextual filter, as mentioned above.

This worked for me today anyway, hope it helps you :)

ehsankhfr’s picture

Use page manager with content ID as the context of the inserted view!