Copied to clipboard

Flag this post as spam?

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


  • M 40 posts 273 karma points
    Apr 26, 2017 @ 10:35
    M
    0

    Hi Everyone,

    I'm having trouble finding information around searching for members on the front end. I'm trying to make a contact list, but I've got a few different member groups and I only want results from one group.

    So far I've got:

    var selection = ApplicationContext.Current.Services.MemberService.FindByUsername(searchName, 0, 10, out totalRecords, 
    global::Umbraco.Core.Persistence.Querying.StringPropertyMatchType.Contains).OrderBy(x => x.Name)
    

    Which searches all the groups. I've tried

    var selection = ApplicationContext.Current.Services.MemberService.FindByUsername(searchName, 0, 10, out totalRecords, 
    global::Umbraco.Core.Persistence.Querying.StringPropertyMatchType.Contains).OrderBy(x => x.Name).Where(x => x.GetValue("MemberGroup") == "GROUP");
    

    but it says MemberGroup doesn't exist. Am I on the right lines? Is there a better way? All help appreciated.

    Thanks

  • M 40 posts 273 karma points
    Apr 27, 2017 @ 09:36
    M
    100

    Seems I was going about this the wrong way. I've ended up using GetMembersByGroup and adding the where clause onto there i.e.

    var selection = ApplicationContext.Current.Services.MemberService.GetMembersByGroup("GROUP").OrderBy(x => x.Name).Where(x => x.Username.ToLower().Contains(@searchName));
    
Please Sign in or register to post replies

Write your reply to:

Draft