We have a separate job for publishing items with some logic. We need to prevent users from accidentally clicking on Publish Site, even Administrators. The regular revoking of 'Publish' item in Core DB doesn't work for Admin.
I created a custom Sitecore command to provide more flexible option for this issue.
I looked into the Sitecore code related to system:publish command which was associated with this "Site publish" menu item and adjust it to support few options which can be changed using config setting.
Basically this will provide you with a Sitecore setting which you can adjust by changing config include file, with options to
- Run the default sitecore publishing operation
- Display a warning message and ignore the publishing
- Hide the menu item from Content Editor
Configuration file looks as follows
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore> <commands> <command type="SitecoreFootsteps.Modules.CustomEditorFullPublishOption.CustomCommand.CustomFullPublish,SitecoreFootsteps.Modules.CustomEditorFullPublishOption" name="scfootsteps:customfullpublish"/> </commands> <settings> <!-- values : enabled : works as default sitecore publishing disabled : display warning message and doesn't trigger publishing hidden : hide the full publish option --> <setting name="SitecoreFootsteps.EditorFullPublishOption" value="enabled" /> </settings> </sitecore> </configuration>
So, if you set the above setting to "hidden", Content Editor "Site publish" option will get hidden
And if you set the setting to "disabled", Content Editor will display "Site publish" option but will return a warning message once clicked and just ignore the publish operation.
You can take a look at the code from following url https://github.com/chaturangar/sitecore-footsteps/blob/master/SitecoreFootsteps.Modules/SitecoreFootsteps.Modules.CustomEditorFullPublishOption/CustomCommand/CustomFullPublish.cs
In that code, just only adjust few places including hiding and displaying message depending on the custom config setting introduced above.
You can find more details from my blog post https://sitecorefootsteps.blogspot.com/2016/11/custom-sitecore-command-to-disable-or.html
You can't hide much for admin users, I would take 2 steps to prevent this happening:
Don't let anyone login as an admin user. Create "CMS Administrator" accounts that have all the access you would need and only ever login to an admin account when there is no other option.
The publish buttons in the CMS that allow a full publish run through the command
system:publish. That is defined in the
If you want to permanently disable the buttons you could override that command so that it doesn't do anything on running the command.
EDIT: New option based on comments
- The publish dialog is in
/sitecore/shell/Applications/Dialogs/Publish/Publish.xml- it uses
Sitecore.Shell.Applications.Dialogs.Publish.PublishForm,Sitecore.Clientas the code behind. You could disable the publish buttons in the SheerUI and add some text to inform the user that publishing manually is restricted.
You can also check the Publishing Restriction module to restrict bulk publish operation, like if you want to restrict the user to publish home node, Media library etc which contains complete tree, then you can use this module..
I was just looking some publishing-related items and found this details,
Although this has been answered but would like to share some more details.
This is a pretty common requirement and the best way to manage this access through the core DB, Below are some simple steps for the reference.
Apart from the correct answer, we can customize the publish wizard, override Default Sitecore
PublishForm class and check for the current logged in user in override void
OnNext method and show custom message to the content author with custom alert message saying 'You do not have access. Please contact administrator' instead of disabling the whole publishing button.
You can find more information on how to customize publishing in the blog link