Copied to clipboard

Flag this post as spam?

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


  • Charlie 14 posts 94 karma points
    Feb 08, 2018 @ 22:55
    Charlie
    0

    Hide certain property editors from certain users

    I have a table with several "brands" outside the umbraco tables. I want a way to link pages to specific brands. Currently I have a text field in the document type I am entering the corresponding brand ID. then in my surface controller I do this

    var BrandsPage = Umbraco.TypedContent(1208);
    var umbBrands = BrandsPage.Children;
    
    var umbBrandPage = umbBrands.FirstOrDefault(x => x.brandID == brand.BrandID);
     brand.Link = umbBrandPage.Url
    

    This is working fine, I would like a more elegant solution, but that is not really what I am looking for here. What I would like to do is hide that BrandID field when content users (besides admins) are editing content. I haven't found a way to do this with Umbraco "Out of the box", if there is that would be awesome, but if not is anything I can do to extend Umbraco to allow functionality like this.

  • Dave Woestenborghs 3325 posts 11170 karma points MVP 5x admin c-trib
    Feb 09, 2018 @ 07:55
    Dave Woestenborghs
    2

    Hi Charlie,

    May you can use the EditorModelEventManager.SendingContentModel event to remove the property when the user is not a admin.

    In this event you can tweak the display model that is sent to the browser.

    More info here ; https://our.umbraco.org/documentation/Reference/Events/EditorModel-Events

    Dave

  • Charlie 14 posts 94 karma points
    Feb 10, 2018 @ 00:03
    Charlie
    0

    My man! that was exactly what I was looking for.

    Thanks so much.

  • Dave Woestenborghs 3325 posts 11170 karma points MVP 5x admin c-trib
    Feb 10, 2018 @ 08:14
    Dave Woestenborghs
    0

    Cool,

    Can you some code how you did it ? Haven't used the event myself.

    Dave

  • 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