Copied to clipboard

Flag this post as spam?

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


  • krisek 16 posts 103 karma points
    Oct 02, 2014 @ 11:06
    krisek
    0

    Hide Content/links if not in Member Group

    Hi, 

    I went throught couple of blogs and tutorials, I also bought the videos from umbraco.tv but still I have problems with understanding everything. That's why I need your help. 

    I went throught this: http://siempresolutions.co.uk/blog/Umbraco_Members_Protected_Area_of_Website

    and now I have login and register page, 2 pages for each of registered users (UserA belongs to GroupA and UserB to GroupB), and some other pages visible for everyone. 

    The questions is: how to hide links which certain users can't access because they don't belong to certain group?

    In my Master template, I have a part of this code:

        

    @Umbraco.Field("pageTitle")

    How Can I display the menu options based on membership? In the finanl effect I want to have a website with login page, after user loggs in, he will see everything what is meant to be there for a certain Member group. 

  • krisek 16 posts 103 karma points
    Oct 02, 2014 @ 14:11
    krisek
    100

    This is what I have till now:

    @{
    var homePage = CurrentPage.AncestorsOrSelf(1).First();
     
    var menuItems = homePage.Children.Where("UmbracoNaviHide == false");
    foreach (var item in menuItems)
    {
      var loginAcces = umbraco.library.IsProtected(item.id, item.path) && umbraco.library.HasAccess(item.id, item.path);
    var cssClass = loginAcces ? "loginAcces ":"";
    cssClass += CurrentPage.IsDescendantOrSelf(item) ? "currentpageitem" :"";                        
     
    if(!umbraco.library.IsProtected(item.id, item.path) || loginAcces){
    <li><a href="@item.id">@item.name</a></li>
    }
    }
    }

    seems to work in 90%.

  • 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