Copied to clipboard

Flag this post as spam?

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


  • Rob Smith 34 posts 165 karma points
    Aug 02, 2013 @ 17:11
    Rob Smith
    0

    Get the Members 'member type' with Razor in Umbraco 6

    Easy if you know I'm sure but I can't seem to get the members member type. I'm just trying to show an extra link in the navigation bar if a member is of a certain member type.

    Here is where I'm at

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using umbraco.cms.businesslogic.member
    @using System.Web  
    @using System.Web.Security
    @*
    Macro to display child pages below the root page of a standard website.
    Also highlights the current active page/section in the navigation with
    the css class "current". 
    *@

    @{ 
    @*Get the root of the website *@
        var root = Model.AncestorOrSelf(1);
    var classtmp = "";
    }
    <ul class="nav">
    <li><a href="/">Home</a></li>

    @foreach (var page in root.Children.Where("Visible"))
        {
    if (@page.id == 1084) {
    classtmp = "join";
    } else {
    classtmp = "";
    }

       <li class="@classtmp @page.IsAncestorOrSelf(Model, "active", "")">
                <a href="@page.Url">@page.Name</a>
            </li>
    }


    @{
      var m = Membership.GetUser();
      if (m!=null)
      { //IF member is of memberType X show this link
      <li><a href="/hiddden-link/">@m.UserName</a></li>
      }
    }

    </ul>
  • Rob Smith 34 posts 165 karma points
    Aug 02, 2013 @ 17:49
    Rob Smith
    100

    I've worked it out :) relevant code below:

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using umbraco.cms.businesslogic.member
    @{
            var m = Member.GetCurrentMember();
            if (m!=null)
            {
                if(@m.ContentType.Alias.ToString()=="MyMemberTypeNameGoesHere") 
                {
                <li class="repsonly"><a href="#">Specific Member Type Link</a></li>         
                }
            }
     }  
    
  • Biagio Paruolo 1621 posts 1914 karma points c-trib
    May 06, 2014 @ 22:05
    Biagio Paruolo
    0

    Works

  • Birger 14 posts 34 karma points
    May 10, 2015 @ 16:37
    Birger
    0

    Is there a way to do this in Umbraco 7?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 10, 2015 @ 16:57
    Dennis Aaen
    0

    Hi Birger,

    In Umbraco 7.1 and 6.2 and newer you can use the services to get a "gateway" to Umbraco data for operations which are related to coment, members, member types and so on see here: https://our.umbraco.org/documentation/reference/management-v6/services/

    For working with members and member types, see this different services.

    https://our.umbraco.org/documentation/reference/management-v6/services/MemberService

    https://our.umbraco.org/documentation/reference/management-v6/services/MemberTypeService

    https://our.umbraco.org/documentation/reference/management-v6/services/MemberGroupService

    For an exampe on how it works perhaps this thread can help you. https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/64649-How-to-Display-a-list-of-Members

    Hope this helps,

    /Dennis

  • Birger 14 posts 34 karma points
    May 10, 2015 @ 20:20
    Birger
    0

    Thank you, I was able to create a (rather ugly) workaround using some of the suggestions from the linked thread. :-)

Please Sign in or register to post replies

Write your reply to:

Draft