Copied to clipboard

Flag this post as spam?

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


  • Craig O'Mahony 364 posts 918 karma points
    Jul 21, 2015 @ 16:33
    Craig O'Mahony
    0

    Show only links where the user has access

    Hi all,

    I've created a razor page that is looping through all of the links on a site and displays a menu (which contains 7 items - one of which I've 'protected' by assigning a user role to it) and what I'm trying to do is hide this menu item if the person that's using the site isn't logged in.

    @{ var child = CurrentPage.Site().Children.Where("Visible"); }
    

    I would have thought that I could HasAccess but whereever I put this it completely hides all menu items.

    Could someone point me in the right direction please?

    thanks, Craig

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Jul 21, 2015 @ 16:40
    Dennis Aaen
    101

    Hi Craig,

    Try to see the documentation under the section member helpers https://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/

    There you have these methods.

    .MemberHasAccess(int nodeId, string path);
    
    .MemberIsLoggedOn()
    
    .IsProtected(int pageId, string path)
    

    Hope this helps,

    /Dennis

  • Craig O'Mahony 364 posts 918 karma points
    Jul 21, 2015 @ 16:56
    Craig O'Mahony
    1

    Good work, you know everything!

Please Sign in or register to post replies

Write your reply to:

Draft