28Aug, 2025
How to Bypass Publish Restrictions on an Item Based on Target
If you saw my post yesterday about adding a preview link to sites, you might come to the conclusion that I've added a 2nd publishing target. Works great, but if publishable dates are set, nothing will get published to this new preview target. I've created a simple processor to handle this.
Understanding the Problem
Ok so I've added a 2nd publishing target and created new steps in Workflows so Authors can publish work in progress items for review without approval. In this image you can see we've extended the standard workflow so those with the right permissions can Publish without Approval, but more importantly anyone has the right to Publish to Preview.

The Publish to Preview command keeps the workflow in its current state and has an action which handles publishing to the Preview target.

Now, Authors on this team regularly use the publish by date restrictions fields, so an item can move through workflow and then appear on the date and time they expect.

Cool, not cool, because even though the Preview target is set as a preview target, the date field will stop this from making it to the private CD.

You can see the Workflow's state has Preview flagged as Preview as well, but that just won't do it. As they say, that dog won't hunt.

Using a Custom Publish Item Processor
This processor is brief, checking the context exists and the target is “preview”. I'm not a fan of magic strings but this is the only place in the solution we need this value.
It it's set to be published here we check if Never Publish is enabled and respect that, unless the config value overrides this.
namespace Sitecore.Foundation.SitecoreExtensions.Pipelines.Publishing { public class CustomPublishItemProcessor : PublishItemProcessor { public override void Process(PublishItemContext context) { if (context == null || context.Action != PublishAction.None) return; if (context.PublishOptions.TargetDatabase.ToString().ToLower() == "preview") { var publishingItem = context.PublishHelper.GetSourceItem(context.ItemId); if (publishingItem == null) return; var publishEvenIfNeverPublish = Configuration.Settings.GetBoolSetting("Sitecore.Foundation.SitecoreExtensions.Pipelines.Publishing.CustomPublishItemProcessor.PublishEvenIfNeverPublish", false); if (publishEvenIfNeverPublish || !publishingItem.Publishing.NeverPublish) { context.VersionToPublish = publishingItem; context.Action = PublishAction.PublishVersion; } } } } }
Patching the Processor
Above you can see we need to patch a processor in and introduce a configurable variable. Here's a sample for what is needed.
<configuration xmlns:patch="http: www.sitecore.net="" xmlconfig="" " xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:set="http://www.sitecore.net/xmlconfig/set/"></configuration xmlns:patch="http:><sitecore> <pipelines> <publishItem> <processor role:require="(UAT or PROD) and CM" patch:before="*[@type='Sitecore.Publishing.Pipelines.PublishItem.DetermineAction, Sitecore.Kernel']" type="Sitecore.Foundation.SitecoreExtensions.Pipelines.Publishing.CustomPublishItemProcessor, Sitecore.Foundation.SitecoreExtensions" /> </publishItem> </pipelines> <settings> <setting name="Sitecore.Foundation.SitecoreExtensions.Pipelines.Publishing.CustomPublishItemProcessor.PublishEvenIfNeverPublish" value="True"/> </settings> </sitecore>