Copied to clipboard

Flag this post as spam?

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


  • Dennis Boonk 4 posts 87 karma points
    Jun 02, 2021 @ 14:44
    Dennis Boonk
    0

    Umbraco Publish permission based on doctype

    Hi,

    Is there a way to give a usergroup publish permission except for one doctype (with 6000> nodes) in Umbraco 8? All the other nodes the user in this group can publish. It's no problem if i need to do something in code.

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    Jun 02, 2021 @ 20:08
    Paul Seal
    0

    Hi I would do this by hooking into the content service publishing event and if the user is not in the required group cancel the event. You should be able to find the required code in this forum, documentation or elsewhere based on the key words I’ve given you there.

    Cheers

    Paul

  • Dennis Boonk 4 posts 87 karma points
    Jun 03, 2021 @ 06:00
    Dennis Boonk
    0

    Hi Paul,

    Thank you very much for your reply. I'm aware of the events. But i don't only want to block it, i want the backoffice to respond correctly. So that the publish button isn't visible in the context menu and in the right bottom corner of the edit screen.

    Cheers, Dennis

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Jun 03, 2021 @ 07:31
    Dave Woestenborghs
    100

    Hi Dennis,

    Don't know if this will work in V8, but have a look at https://our.umbraco.com/Documentation/Reference/Events/EditorModel-Events/

    Maybe you can remove publish from the allowed actions of the ContentItemDisplay model : https://our.umbraco.com/Documentation/Reference/Events/EditorModel-Events/#contentitemdisplay

    In V7 I was able to remove the unpublish button for everybody that was not in admin with the following bit of code

    private void EditorModelEventManager_SendingContentModel(HttpActionExecutedContext sender, EditorModelEventArgs<ContentItemDisplay> e)
        {
            var contentItemDisplay = e.Model;
            var context = e.UmbracoContext;
    
            this.HideActionButtons(contentItemDisplay, context);
        }
    
        private void HideActionButtons(ContentItemDisplay contentItemDisplay, UmbracoContext context)
        {
            var usergroups = context.Security.CurrentUser.Groups.ToList();
    
                if (contentItemDisplay.ContentTypeAlias == "MyAalias")
            {
                if (usergroups.Exists(x => x.Alias == "admin") == false)
                {
                    // remove unpublish actions, because if editor removes this it will break the site
                    contentItemDisplay.AllowedActions = contentItemDisplay.AllowedActions.ToList().Where(x => x != "Z");
                }
    
            }
        }
    

    Dave

  • Dennis Boonk 4 posts 87 karma points
    Jun 15, 2021 @ 07:22
    Dennis Boonk
    0

    Hi Dave,

    Thank you very much! This is exactly what I was looking for. It works great also in v8.

    Dennis

Please Sign in or register to post replies

Write your reply to:

Draft