Copied to clipboard

Flag this post as spam?

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


  • tecarter 4 posts 20 karma points
    Feb 05, 2009 @ 23:13
    tecarter
    0

    Accessing the Member Type of the current member

    I was wondering if anyone knows of a way to get the member type of the current member that is logged in? I was guessing that the following might work, but it did not so I'm back to square one.



    Thanks in advance.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Feb 06, 2009 @ 08:52
    Dirk De Grave
    0

    Hi,

    @nodeTypeAlias is what you're looking for.
    Be aware though that @nodeTypeAlias is returning the... alias. If you can live with that, that's fine, if you need the exact member type's name, you'll need some code to get the type name based on the alias (Either inline c# script or through xslt extensions - the latter would be overkill here)

    To get the name based on alias, use MemberType.GetByAlias(string alias)

    Hope this helps.

    Regards,
    /Dirk

  • tecarter 4 posts 20 karma points
    Feb 06, 2009 @ 15:50
    tecarter
    0

    Thanks! That is exactly what I wanted.

  • Nigel Wilson 945 posts 2077 karma points
    Dec 15, 2009 @ 22:11
    Nigel Wilson
    0

    Sorry to reactivate an old post but is anyone able to provide an example of an xsl:if statement that checks MemberType.GetByAlias(string alias) witihn an xslt.

    I am looking to build a member navigatoin that is based on member type.

    Thanks in advance.

  • Nigel Wilson 945 posts 2077 karma points
    Dec 16, 2009 @ 02:01
    Nigel Wilson
    1

    Further to my earlier post I thought I'd post a snippet of code I have just written - maybe someone else with the same predicament will find it useful:

    String memberLoginName = Member.GetCurrentMember().LoginName;
    MembershipUser User = Membership.GetUser(memberLoginName);
    Member member = new Member((int)User.ProviderUserKey);

    if (member.ContentType.Text == MemberType.GetByAlias("CompanyEmployee").Text)
    {
    memberList.Text = "I am a Company Employee member type";
    }
    else if (member.ContentType.Text == MemberType.GetByAlias("CompanyRecord").Text)
    {
        memberList.Text = "I am a Company Record member type";
    }

    Maybe there is a better way but this can be wrapped up into a macro and output on the page.

Please Sign in or register to post replies

Write your reply to:

Draft