We have many Sitecore admin users in Sitecore. I want Full site publish only allowed to some admin users and not to all admin users.
We can't hide the "Publish Site" option as some of the admin require to access it. When any other admin user, who is not from authorized admin user list, try to publish the full site, I want to cancel the publish operation itself. Below is the code which I am referring to cancel the operation on publish:begin event, but unfortunately, its not cancelling the publishing operation?
public void OnPublishStart(object sender, EventArgs args)
{
try
{
Publisher publisher = Sitecore.Events.Event.ExtractParameter(args, 0) as Publisher;
if (publisher.Options.Mode == PublishMode.Full || publisher.Options.Mode == PublishMode.Smart || publisher.Options.Mode == PublishMode.Incremental)
{
((SitecoreEventArgs)args).Result.Cancel = true;
publisher = null;
args = null;
sender = null;
return;
}
}
catch (Exception ex)
{
Log.Error("Error : " + ex.ToString(), this);
}
}
Do anybody have any workaround to cancel the publish site operation programmatically?