Skip to content

Instantly share code, notes, and snippets.

Created October 19, 2021 08:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Prevent running of NotBot JS based on other factors on site
<?php declare( strict_types=1 );
* Use this filter to tell Shield to NOT run the NotBot JS system.
* If you disable the NotBot JS system then you will likely lock-out visitors.
* Use of this filter is at your own risk.
add_filter( 'shield/can_run_antibot', function ( $canRun ) {
// $canRun defaults to true.
// You can change this to false based on particular settings on your site.
// For example, since NotBot uses a cookie, you could say that if a particular
// consent cookie isn't set, disable the NotBot JS.
if ( empty( $_COOKIE[ 'cookie_consent_set' ] ) ) {
$canRun = false;
// ALWAYS return $canRun.
return $canRun;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment