Skip to content

Instantly share code, notes, and snippets.

@victormattosvm
Last active May 27, 2022 13:13
Show Gist options
  • Save victormattosvm/4a1781413816fb7aa8733d5c8ff6920a to your computer and use it in GitHub Desktop.
Save victormattosvm/4a1781413816fb7aa8733d5c8ff6920a to your computer and use it in GitHub Desktop.
Fix for "anr_error" when using WPGraphQL or WP REST API with Captcha4WP (old Advanced Nocaptcha & Invisible Captcha)
<?php
/**
* This code disables the Captcha verification when using WPGraphQL or WP REST API
* It fixes the "anr_error" issue.
*
* Put this code in your functions.php
*/
add_action(
'rest_api_init',
function() {
if ( class_exists( 'anr_captcha_class' ) ) {
remove_filter('authenticate', array( \anr_captcha_class::init(), 'login_verify'), 999, 3);
}
}
);
add_action(
'init_graphql_request',
function() {
if ( class_exists( 'anr_captcha_class' ) ) {
remove_filter('authenticate', array( \anr_captcha_class::init(), 'login_verify'), 999, 3);
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment