I see you have added a check in gglcptch_is_recaptcha_required function which is causing issues in my theme.
I use your plugin for captcha verification via WP AJAX requests (admin-ajax.php) but this check prevents the form from being validated because it always returns true:
if ( wp_is_json_request() ) { return false; }
I use jQuery to submit the contact form $.post( url, data, ... )
You should exclude jQuery requests done in admin-ajax.php in this place.
Please clarify the problem. You have a form that is submitted via admin-ajax.php. It contains our captcha. And it always passes the test, because this condition is triggered
The form is submitted via AJAX and so it gets the g-recaptcha-response field on post request. Then in wp_ajax_process_contact_form hook I try to validate the captcha using this hook:
It used to work in the past and returned false when captcha was invalid, but now it returns always true, and after investigating I have found that the issue is related here:
So the real problem stands here:
If I comment this line it works as expected.
The problem is that the request in AJAX from jQuery is sent using $.post( … ) as JSON type becuase it expects the response to be given in JSON as well.
My advice is that you should differentiate the requests made in the REST API and admin-ajax.php file.
Thank you. Could you please send us your entire $_POST so that we can highlight some feature and allow us to apply a filter or throw an exception? Thank you.
I have this values on my form. I don’t spent much time to learn code of you plugin (will do this later if will not find solution), but which function from plugin i can use and past this value and check result? Or you can suggest any other solutions for custom ajax forms? Thank you.