Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Shaun 248 posts 475 karma points
    Jun 18, 2010 @ 11:31
    Shaun
    0

    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

     

     

  • Shaun 248 posts 475 karma points
    Jun 18, 2010 @ 12:00
    Shaun
    0

    sussed it. I was using the hashtable the wrong way

         int intmygroup = MemberGroup.GetByName("mygroup").Id;           
         bool ingroup = member.Groups.ContainsKey(intmygroup);
  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Jun 18, 2010 @ 13:37
    Matt Brailsford
    0

    You could also use the in built .NET Roles provider

    Roles.IsUserInRole(member.LoginName, "mygroup")

    Matt

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies