Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Get a list of a Members Groups?

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1972 Views
  • Gutur
    Avatar
    Community Member
    17 Posts

    Get a list of a Members Groups? Link to this post

    Hi there,

    the basic idea is that I have entries in the DB that "belong" to a certain user (I store the creators UserID in the DB).
    Users who are in one of the groups as this "owner" are allowed to view the entry.

    What baffles me, how do I get a list of groups a user is in?
    For instance "Member::currentMember() ? Member::currentMember()->Groups()" gives me a "ComponentSet" and not a list of GroupIDs and I can't figure out how to get a list of GroupIDs for a certain UserID out of this...

    Anyone an idea for me?

    Thanks in advance /Carsten

  • Gutur
    Avatar
    Community Member
    17 Posts

    Re: Get a list of a Members Groups? Link to this post

    Me again, got the answer on IRC from simon_w:
    Permission::groupList($member->ID);
    gives a nice array of all the group IDs that the user is in.
    Thus I can feed it directly to inGroups() on another user to see if they share a group ;)
    /Carsten

    1972 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.