Skip to content

Instantly share code, notes, and snippets.

@paulgoodchild
Created October 19, 2021 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulgoodchild/9e996ec9b42301b768496d13a1253d55 to your computer and use it in GitHub Desktop.
Save paulgoodchild/9e996ec9b42301b768496d13a1253d55 to your computer and use it in GitHub Desktop.
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