Kentico: Roles and staging – excluding items from the staging queue

If you’re using roles and the staging module in Kentico, a change to the role record will not only push through that record, but will synchronise the related user-role entries as well. Once the role has been staged, your user-roles on the destination environment will be the same as on the source (users will be added or removed from the role). Depending on how you’re using staging with your environments, this may not be desired behaviour. This article explores one way to manage this – how you can exclude roles from being staged (or other objects!), without affecting any other staging settings.

Excluding items from the Kentico staging queue

Using the approach outlined by Jaroslav, we can prevent certain changes from being added to the staging queue. You can exclude all items of a specific type, or even by object/type name (or other properties like path of document). Here’s an example StagingEventFilter class that you can use, which excludes roles and contains example of excluding both structural and data changes to the sample custom table. Just drop it into your Kentico 8 App_Code folder for it to work.

If you decide to expand this class with more complex rules, or decide to only exclude a certain branch of your content tree from staging, make sure you’re comfortable with the relationships between your data – if Page A is not staged, but Page B is… and Page B depends on Page A in order to work, you might have some problems. Exclude from the staging queue with care, and test the effect thoroughly on each site.

Other Kentico versions

I’ve experienced this behaviour in Kentico 7 and 8. It’s possible it affects both earlier and later versions. The StagingFilter approach to solve it works with both Kentico 7 and 8, though older versions might require the StagingFilter class to be hooked into Kentico in a slightly different way.

Leave a Comment.