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 95 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 3504 posts 12135 karma points MVP 9x 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 95 karma points
    Feb 10, 2018 @ 00:03
    Charlie
    0

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

    Thanks so much.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x 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

  • Gerhard Grossberger 55 posts 179 karma points
    Dec 01, 2021 @ 08:41
    Gerhard Grossberger
    0

    Hi, following up on that topic. we´re using Umbraco 9, so I guess we need to use SendingContentNotification https://our.umbraco.com/documentation/Reference/Notifications/EditorModel-Notifications/

    So when an article is called

    • check the doctype
    • check the user type for admin
    • hide/remove the property

    Is there a simpler way, some plugin that does that?

    Best, Gerhard

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Dec 01, 2021 @ 10:29
    Dennis Aaen
    1

    Hi Gerhard

    Perhaps you can use or get some inspiration from this thread

    https://our.umbraco.com/forum/umbraco-9/106763-hideremove-property-via-notificationeditoremodel

    Hope this helps,

    /Dennis

  • 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