Copied to clipboard

Flag this post as spam?

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


  • Michael Nielsen 99 posts 619 karma points
    Jun 18, 2014 @ 14:59
    Michael Nielsen
    0

    MemberService.GetMembersByMemberType

    Trying to get a list of members in a Partial View, but I'm getting a Compilation Error

    CS0120: An object reference is required for the non-static field, method, or property 'Umbraco.Core.Services.MemberService.GetMembersByMemberType(string)' 

    Reference documentation: http://our.umbraco.org/documentation/Reference/Management-v6/Services/MemberService ;

    Umbraco v. 7.4.1

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using Umbraco.Core;
    @using Umbraco.Core.Models;
    @using Umbraco.Core.Services;
    
    @foreach(var member in MemberService.GetMembersByMemberType("Member")){
    }
  • Michael Nielsen 99 posts 619 karma points
    Jun 18, 2014 @ 15:25
    Michael Nielsen
    101

    Solved it by doing the following

    But I would love to hear if there is an "easier" or more "standard" way to do it

    foreach(var member in ApplicationContext.Current.Services.MemberService.GetMembersByMemberType("Member")){
    listMember = Members.GetByEmail(member.Email);
    
    @listMember.GetPropertyValue("customProperty")
    }
    
  • 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