Disable Right Click and Copy Events from WordPress Frontend

By ThemesDNA1 min read

Share:

Do you want to prevent users from copying the content of your WordPress website? By using the PHP snippet given below, it will stop users from right-clicking on your website and copying the content of your website. Add it to your theme's functions.php file:

function themesdna_disable_right_click_copy_events() {
    ?>
    <script>
    document.addEventListener("contextmenu", (evt) => {evt.preventDefault();}, false);
    document.addEventListener("copy", (evt) => {
      evt.clipboardData.setData("text/plain", "You do not have permission to copy our content.");
      evt.preventDefault();
    }, false);
    </script>
    <?php
}
add_action('wp_head', 'themesdna_disable_right_click_copy_events');
Premium WordPress themes Made for WordPress   /   Ready for your story

Ready to Build?

Your next great website starts here.

Build more websites with one flexible collection—and keep every theme for life.

  • 56+ themes
  • Lifetime updates
  • Unlimited websites
  • No renewals

The complete collection

$75

One payment. No renewals.

Get the Themes Bundle — $75