I can't figure out how to create a view listing all nodes from the logged-in user groups. This was easy with Drupal 6 version of Organic groups, but with the entity based version, it is not obvious (or maybe not doable without some views data hooks).

Thanks for your help.

2 Answers 2


I've interpreted this question as asking how to set up a View which displays all content published by the current user in the groups he or she belongs to.

Assuming that you have your group set up correctly and a group content type (content that belongs to the group), you should be able to filter by group membership in the following manner:

  1. Create a node View
  2. Add a Node group membership relationship
  3. Add a Group membership: Node group membership contextual filter (argument in D6)
  4. While setting up the contextual filter, select "Provide default value" under the fieldset titled "when the filter value is NOT in the URL."
  5. Insert the following code:

    global $user;
    $all_groups = db_query('SELECT gid FROM {og_membership} WHERE etid = :uid', array(':uid'   => $user->uid));
    $groups_array = array();
    foreach($all_groups as $group){
      $groups_array[] = $group->gid;
    $groups_string = implode('+', $groups_array);
    return $groups_string;
  6. Make sure that you don't provide a way for users to supply their own contextual filter through the URL, otherwise your default contextual filter won't be used.

  7. Under the "Extra" fieldset at the bottom (click to expand), check "Allow Multiple Values." Save the contextual filter.

  8. Create a normal filter for "User:Current" to limit results to those authored by the current user.

Something along those lines should do the trick.

  • Thank you areynolds. I've used a similar approach since then, but my concern is that this cannot be done using relationships, without this kind of extra queries... The D7 version of OG forces us to do nasty things like this it seems.
    – Jide
    Aug 27, 2011 at 12:35
  • Know what you mean, every extra join breaks a little more of my heart...
    – areynolds
    Aug 28, 2011 at 15:41

In Views you can use User: Current under "Filter Criteria" to filter the view results.

  • You have to add "Content: Author" under Relationships, for Adam S tip to work. (I just thought I would mention that as it took me a while to work it out!)
    – big_smile
    Apr 17, 2012 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.