Create a View of Organic Group Members

Create a View of Organic Group Members

An OSTraining member was setting up the Organic Groups module in Drupal.

They asked us if it was possible to show the members of one particular group. Yes, that’s possible using Views.

In fact, Views ships with a default view that is very similar to this task. We’re going to clone that view and make some small changes.

  • Make sure you have Organic Groups and Views set up.
  • Go to Structure > Views.
  • Find the “OG members” view.
  • Click “Clone”.
Cloning a OG members view

Look on the right-hand side of the View, under “Advanced”.

The key to creating a view of OG members is this relationship: “OG membership: OG membership from User”.

The OG membership: OG membership from User relationship
  • On the left-hand side, click “Add” next to “Filter Criteria”.
Adding a new filter criteria in Views
  • Search for “OG membership: Group ID”.
Adding OG membership: Group ID in Views
  • Click “Apply (all displays)”.
  • Under “Relationship”, choose the relationship that is on the view.
  • For “Operator”, choose the Node ID of the Organic Group you are targeting. Here’s a tutorial on finding the Node ID. In my example, the Node ID is 32.
Entering the Node ID of an Organic Group into Views
  • Save the filter and save your view.
  • Your view should now be showing users only from a single Organic Group.

Author

  • Steve Burge

    Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x