Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi
I'm trying to check a member to see if he's in a particular group using the api.
I've got a member, and the group I'm testing for is called "mygroup".
Response.Write(member.Groups.ContainsValue("mygroup").ToString()); returns false.
I've also tried getting the id number of the group and passing that
int intMyGroupID = MemberGroup.GetByName("mygroup").Id;
Response.Write(member.Groups.ContainsValue(intMyGroupID).ToString());
but I'm still getting nothing.
I've checked and my member is definately a member of the group.
What am I doing wrong?
Many thanks
Shaun
sussed it. I was using the hashtable the wrong way
int intmygroup = MemberGroup.GetByName("mygroup").Id; bool ingroup = member.Groups.ContainsKey(intmygroup);
You could also use the in built .NET Roles provider
Roles.IsUserInRole(member.LoginName, "mygroup")
Matt
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
how to get a members groups using the api
Hi
I'm trying to check a member to see if he's in a particular group using the api.
I've got a member, and the group I'm testing for is called "mygroup".
Response.Write(member.Groups.ContainsValue("mygroup").ToString()); returns false.
I've also tried getting the id number of the group and passing that
int intMyGroupID = MemberGroup.GetByName("mygroup").Id;
Response.Write(member.Groups.ContainsValue(intMyGroupID).ToString());
but I'm still getting nothing.
I've checked and my member is definately a member of the group.
What am I doing wrong?
Many thanks
Shaun
sussed it. I was using the hashtable the wrong way
You could also use the in built .NET Roles provider
Matt
is working on a reply...