Skip to content
Advertisement

Disable Right Click on WordPress Site

I wanted to disable right click on my wordpress site. I have written a small snippet and inserted into body which disables right click, CTRL events and keyups.

JavaScript

but it is annoying when I want to copy something on site. is there a way I can modify the current snippet like only logged in users would be able to access the disabled events?

Cheers.

Advertisement

Answer

First I have created a JS page in the directory named: “preventcopy.js” and added restricted the events using below JS

JavaScript

and then in function.php I enabled access for logged in users as below.

JavaScript

That’s how it is been accomplished. But I would highly suggest enabling these features for users considering the user experience.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement