It is quite dirty indeed. Essentially I need the group Id's the member belongs to.
var memberRoles = System.Web.Security.Roles.GetRolesForUser(member.Username).ToList();
var memberInGroups = new List<int>();
foreach (var role in memberRoles)
{
var group = MemberGroupService.GetByName(role);
memberInGroups.Add(group.Id);
}
Seems to work but probably not the way I wanted to write it.
Find which groups a member belongs to
Hi,
How can I get a list of groups that a single (current) member belongs to? I have an instance of IMember but I can't see groups.
The the old way, you could do something like
Whats the best way using the API?
Thanks, /B
can you not do a foreach on the
Problem is currentMember is not an IMember. And IMember doesn't expose Groups.
The closest thing I could find to getting groups/roles for a member is using System.Web.Security.Roles.GetRolesForUser
I was going to say unless you are willing to work the wrong way round, ie.
get all the roles and then check if the user is in those roles?? though that feels like a pfaff/dirty workaround..
It is quite dirty indeed. Essentially I need the group Id's the member belongs to.
Seems to work but probably not the way I wanted to write it.
sounds like an API extension issue that needs to be raised.. the list of groups by member
is working on a reply...