In Sitecore workflow it is very easy to restrict content authors from approving (and therefore publishing) their own content changes. All you need to do is create a custom workflow action and a very simple C# class.
Create a Custom Workflow Action
Create a new action item beneath the approve step in your workflow, based on the /sitecore/templates/System/Workflow/Action template.
In the “Type String” field, specify the assembly to our custom class:
Sitecore.Feature.Common.Workflow.Actions.ValidateApprover, Sitecore.Feature.Common.Workflow
ValidateApprover Class
namespace Sitecore.Feature.Common.Workflow.Actions { /// <summary> /// Workflow action that ensures the user who created or updated a post cannot approve their own post /// </summary> public class ValidateApprover { public void Process(Sitecore.Workflows.Simple.WorkflowPipelineArgs args) { if (string.Compare(args.DataItem.Statistics.UpdatedBy, Sitecore.Context.User.Name, true) != 0) { return; } Sitecore.Web.UI.Sheer.SheerResponse.Alert("You cannot approve your own changes."); args.AbortPipeline(); } } }
See it in Action
When a content author tries to approve their own change, they will get an alert, and are blocked from approving. The workflow state does not change.
Note that the content author can still reject their own change. In most cases this is a good thing, so they can undo a mistake they might have made. If you want to prevent this, just copy the “Validate Approver” item underneath the “Reject” command.
References
- https://community.sitecore.net/technical_blogs/b/sitecorejohn_blog/posts/repost-prevent-sitecore-reviewers-from-approving-their-own-changes
- https://web.archive.org/web/20110907164216/http://trac.sitecore.net/Library/wiki/Documentation
- https://web.archive.org/web/20110908024359/http://trac.sitecore.net:80/Library/browser/Trunk/Workflow/Actions/ValidateApprover.cs
I found that this no longer worked (as of 2 Jan 2019) and that the solution was to set the “Type String” field to “Sitecore.Feature.Common.Workflow.Actions.ValidateApprover” instead of “Sitecore.Feature.Common.Workflow.Actions.ValidateApprover, Sitecore.Feature.Common.Workflow”