I have created one group using the Group module, then I added some members in that group. Now I want to get list of all members in the group from some custom code.

How do I get the list of all group members?


You can build a view using the Views UI, then export the view, and integrate that exported View in your custom code.

For the actual view, you should create a view of "Group Memberships", and optionally add a filter by Group ID (=gid).

For an example of such view, refer to my answer to "How to add a column to the list of group members or create a Views equivalent of it?", which includes a view (in export format), which should be pretty close to what you're asking for.

| improve this answer | |

Use the Group module API.

| improve this answer | |
  • 1
    Can you give a more complete example? For example, how do you get $group to begin with? – rooby Aug 26 '15 at 12:50

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