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>
@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>
}
}
}
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
I've worked it out :) relevant code below:
Works
Is there a way to do this in Umbraco 7?
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
Thank you, I was able to create a (rather ugly) workaround using some of the suggestions from the linked thread. :-)
is working on a reply...