Copied to clipboard

Flag this post as spam?

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


  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Oct 21, 2009 @ 12:08
    Morten Christensen
    0

    Getting MemberType from Member

    Hi All,

    I'm creating some different lists of Members from the Member section, and want to limit/populate the lists with Members based on their MemberType. My problem is that I don't see this property anyway (only when creating a new member).

    Does anybody know if the MemberType is part of the properties I can get from calling:

    "member.getProperty("MemberType").Value" or something similar.

    The three types of members I'm creating lists for are in the same MemberGroup, so "if (member.Groups.ContainsKey(memberId))" is not an option. But I want to do something similar with MemberType if this is possible.

    Umbraco version 4.0.2.1
    ASP.NET 3.5

    Thanks,

    - Morten

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Oct 21, 2009 @ 12:28
    Richard Soeteman
    3

    Hi Morten,

    I think you could use member.ContentType

    Cheers,

    Richard

     

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Oct 21, 2009 @ 13:36
    Morten Christensen
    1

    Works like a charm!

    Thanks Richard.

    For reference my code (and check in if-statement) ended up looking like this (List of members narrowed by MemberGroup and MemberType):

                List<Member> list = new List<Member>();
                Member[] getAll = Member.GetAll;
                int memberId = umbraco.cms.businesslogic.member.MemberGroup.GetByName(MemberGroup).Id;
                foreach (Member member in getAll)
                {
                    if (member.Groups.ContainsKey(memberId) && member.ContentType.Alias.Equals("MemberTypeAlias"))
                    {
                        list.Add(member);
                    }
                }
                list.Sort((a, b) => a.LoginName.CompareTo(b.LoginName));
                return models;

  • Muhammed A Salam 13 posts 35 karma points
    Aug 06, 2012 @ 14:00
    Muhammed A Salam
    2

    Hi Morten,

     

    For more performance you may try this, so that it doesnt loop through all the members. 

     

     foreach (umbraco.cms.businesslogic.Content content in Member.getContentOfContentType(MemberType.GetByAlias(" MemberTypeAlias ")))

                {              

                    Member member = new Member(content.Id);

                        //eg

                        string name= member.getProperty("MemberType").Value;

               }

  • Gavin Lyons 13 posts 71 karma points
    Jul 18, 2013 @ 09:46
    Gavin Lyons
    0

        var m = Member.GetCurrentMember();

        string mtAlias = m.ContentType.Alias;

        var mt = MemberType.GetByAlias(mtAlias);

     

  • Gawein 1 post 22 karma points
    Dec 02, 2015 @ 18:13
    Gawein
    1

    Post is a bit outdated but when you search Google for this subject you end up here. So here is the latest method:

    List

Please Sign in or register to post replies

Write your reply to:

Draft