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 55 posts 260 karma points
    Apr 20, 2020 @ 11:57
    Johannes Lantz
    0

    Member groups

    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 7 posts 97 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 55 posts 260 karma points
    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?

  • 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