Copied to clipboard

Flag this post as spam?

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


  • Steve Morgan 1345 posts 4452 karma points c-trib
    Mar 06, 2015 @ 12:41
    Steve Morgan
    0

    Members.GetCurrentMember() - check if Member belongs to a Member Group

    Hi,

    I'm sure I'm missing something obvious but is there a missing property of UmbracoMemberGroups? How do you tell if the current logged in user belongs to a certain group? 

    I'm trying to customise a logged in view depending on wether a user is "basic" or "full". The only way I can see to do it is to double up and create my own property and store the groups again? Surely I'm missing something obvious!

    Steve

  • Kevin Jump 2309 posts 14673 karma points MVP 7x c-trib
    Mar 06, 2015 @ 13:23
    Kevin Jump
    105

    Hi

    Try Members.IsMemberAuthorized - you can pass in a list of groups to check if the user is in them or not.

    List<string> groupList = new List<string>();
    
    ...
    if ( Members.IsMemberAuthorized(allowGroups: groupList) ) 
    {
    
    
    }
    
  • Halden Collier 4 posts 84 karma points
    Feb 02, 2021 @ 10:28
    Halden Collier
    0

    Is there no way to do this for a specific member? All the documentation I have found only outlines doing this for the 'CurrentUser'.

    It would be nice to have a function like this:

    objMemberService.IsMemberInGroup(member: objMember, groupName: "Group Name");
    
  • Steve Morgan 1345 posts 4452 karma points c-trib
    Mar 06, 2015 @ 16:01
    Steve Morgan
    0

    Perfect - I would have expected a method under from the MemberHelper but I supose this is because it's IPublishedContent?! Either way that works. 

  • Huw Reddick 1702 posts 5999 karma points MVP c-trib
    Feb 02, 2021 @ 10:42
    Huw Reddick
    0

    you can also use the .net security for this

    User.IsInRole(groupName)

Please Sign in or register to post replies

Write your reply to:

Draft