Skip to main content

Removing Access to Copy and Paste

Zuora

Removing Access to Copy and Paste

Some companies wish to stop end users from being able to copy and paste the content on their site, which adds another layer of protection against users sharing content.

This can be done in Zephr using an entitlement, a UI component, and a feature rule.

Removing Access to Copy & Paste

First, navigate to Entitlement Manager > Entitlements and create an entitlement called ‘Copy and Paste’.

Add the entitlement to any relevant bundles to determine which users will be able to copy and paste content. For example, if this feature is for Subscribers only, then add it to the bundle users received when they pay for their subscription.

Navigate to UI > UI Components and click Add UI Component. Then, add the following script to your UI Component:

<script>
window.addEventListener('load', function() {
document.body.addEventListener('copy', function(e){
console.log('copy/paste disabled..');
e.clipboardData.setData('text/plain', 'boo');
e.clipboardData.setData('text/html', 'boo');
e.preventDefault();
});
});
</script>

Click Save, then navigate to Rules > Feature Rules and create a new rule called Copy and Paste. Note: This rule will need it’s own Zephr Comment Tags, which you will need to wrap around content (separate to any Article tags you are already using).

Within the Rule, add an Entitlement Check for your Copy and Paste Entitlement. If yes, choose No Transformation. If no, choose UI Component, and select your copy-and-paste UI component. The rule should look similar to this:

Copy the Zephr Feature Tags from the ‘Site Integration Tip’ and add these to the body of all pages you wish to limit copy and paste access to.

Save and publish your rule.