How to Disable right click in Xenforo 2

  • Join us to download any resource for free. You will be able to download or guest post.
    Sign Up Now

VU Assistant

Moderator
Staff member
Apr 12, 2022
47
1
8
Is there any way to disable right click and F12 in xenforo? I just want it disabled for guests only.
 

kashif

Administrator
Staff member
Apr 12, 2022
2,522
43
48
Pakistan
www.vuinsider.com
Here is what I found.

Goto Admin Control Panel > Appearance > Templates > edit "PAGE_CONTAINER"

Paste this code at the end, just before the "</xf:macro>" tag.

Code:
<xf:if is="!{$xf.visitor.user_id}">
<script type="text/javascript">
<!--

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="You need to login to right click";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

// -->
</script>
</xf:if>
 
  • Like
Reactions: VU Assistant

About us

  • Our community has been around from 2017 and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. Providing Free Resources to help newcomers/startups. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu

AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock