Copied to clipboard

Flag this post as spam?

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


  • Damien Holley 180 posts 541 karma points
    Nov 13, 2017 @ 11:02
    Damien Holley
    0

    Member Group Picker is only returning the first group

    Basically it only ever returns the first group picked as a single string.

    So I do the below and I only ever get the first result.

    objectNode.GetPropertyValue("nameOfProp");
    

    Anybody had similar or any solutions?

  • Steve Morgan 1348 posts 4457 karma points c-trib
    Nov 13, 2017 @ 11:20
    Steve Morgan
    0

    Hi Damien,

    This works for me - any use??!

    @using Umbraco.Core.Services;
    @{
        Layout = "master.cshtml";
    } 
    
    
    @{
        var memberGroupStrs = Model.Content.GetPropertyValue<string>("memberGroup").Split(',');
    
        foreach (var curMemberGroupStr in memberGroupStrs)
        {
            var memberGroup = ApplicationContext.Current.Services.MemberGroupService.GetByName(curMemberGroupStr);
            if (memberGroup != null)
            {
    
                <h3>@curMemberGroupStr - @memberGroup.Id - @memberGroup.Name</h3>
                }
            }
    
        }
    

    If you just need the group name don't bother with the service (as it might be hitting the DB to do the getbyname.

  • Damien Holley 180 posts 541 karma points
    Nov 14, 2017 @ 10:31
    Damien Holley
    0

    Thanks for the reply Steve, but the property on the object itself is only returning the first of the selected member groups.

    So for example I have a node that is limited to financial and testing in the property limitToGroups.

    When I hit the code below:

      var memberGroupStrs = Model.Content.GetPropertyValue<string>("limitToGroups")
    

    memberGroupStrs is only equal to whichever group I selected first. So if financial was the first group selected on the memberGroup Picker but testing was also selected on it, memberGroupStrs would only be equal to "financial".

Please Sign in or register to post replies

Write your reply to:

Draft