Copied to clipboard

Flag this post as spam?

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


  • Johannes Lantz 156 posts 838 karma points c-trib
    Apr 20, 2020 @ 11:57
    Johannes Lantz
    0

    Hello!

    I am having troubble finding documentation for member groups.

    I have a member group picker, wich returns the member group ID's. But I am having touble figuring out how to get the meber group ID from current logged in member.

    The closest I have gotten is this Members.GetUserRoles(member.Email).FirstOrDefault() but that only gives me the name.

    I am so lost right now. Dose anyone know how I could accomplish this

    Thanks!

    //Johannes

  • Renante 9 posts 125 karma points
    Apr 21, 2020 @ 15:54
    Renante
    100

    How about using MemberGroupService.

    With that, you can get the id by passing the group name here Services.MemberGroupService.GetByName("groupNameHere").Id.

  • Johannes Lantz 156 posts 838 karma points c-trib
    Apr 21, 2020 @ 20:37
    Johannes Lantz
    1

    Thank you so much Renate!

    So the code will look like this...

    var member = Membership.GetUser();
    var membergroupId = Services.MemberGroupService.GetByName(Members.GetUserRoles(member.Email).FirstOrDefault()).Id;
    

    I can't help feeling that there is a much simpler way of doing this.. It feels like I am doing it wrong. Any tought @Renate?

Please Sign in or register to post replies

Write your reply to:

Draft