Skip Navigation

[Resolved] Recaptcha not working in Toolset forms

This thread is resolved. Here is a description of the problem and solution.

Problem:
My Toolset Forms with ReCaptcha are not working as expected.
When submitting them no ReCaptcha field is shown, but then an error is produced:

This post was not saved because of the following problem: Missing CAPTCHA

Solution:
This could be due to minified or optimized scripts.
If you use any minification or optimization plugin, please exclude these scripts (including recaptcha-v2/api.js) from it:
https://toolset.com/faq/how-to-use-optimization-plugins-with-toolset/

100% of people find this useful.

This support ticket is created 5 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 5 replies, has 3 voices.

Last updated by Yann Bigant 5 years, 2 months ago.

Assisted by: Beda.

Author
Posts
#1321973

Someone just tried to use one of our CRED forms (a contact form that had been working recently) and they received an error message - as below:

This post was not saved because of the following problem:
Missing CAPTCHA

This is the field used in my form and in Settings the keys in the reCAPTCHA API have been there for a long time.

[cred_field field='recaptcha' value='' urlparam='']

This is same issue I had here, but upgrade didn't resolve: https://toolset.com/forums/topic/recaptcha-not-showing-on-form-since-latest-update/#post-587195

hidden link

#1322007

I see the erratum is resolved:
https://toolset.com/errata/cred-1-9-2-1-types-2-2-17-18-showstopper-when-using-cred-forms-with-recaptcha/
That's actually an extremely old issue, there were many updates meanwhile.

Was the issue present on your site for the last 2 years, or just popped back up recently?
I see your above description is the same as 2 years ago, hence I assume it never was different, and now updating the plugin, didn't solve the issue?

I also see on hidden link, there is no Recaptcha to fill out.
It's hence unexpected that the form would ask for one later.

The strange is, your form includes the field:

<div class="form-group">[cred_field field='recaptcha' value='' urlparam='' class='form-control' output='bootstrap']</div>

But it is not visible on the front end.

I see a row of JS Errors in the console, which could be the reason for this all.
1. Uncaught ReferenceError: Main is not defined
2. Uncaught ReferenceError: wptValidationForms is not defined
3. Uncaught SyntaxError: Invalid regular expression flags
4. Uncaught TypeError: jQuery(...).sortable is not a function
5. Failed to load resource: the server responded with a status of 404 ()

None of these are sourced in Toolset files.
Instead, cache and Theme files seem to be the involved code parts.

Can you confirm this issue persists without any other plugin? At least the JS errors should be gone by then, and we could proceed to analyze the Forms issue if persisting.

It would be best doing that on a staging site.

#1323747

It was resolved initially - after I logged the issue for the first time, after the software update. It's reappeared recently again. I will have a look at all the errors and remove all plugins and see if I can see the Recaptcha then. I'll let you know. Thanks for your help.

#1323801

My issue is resolved now. Thank you!

In case it might help someone else.

It was Autoptimize that was causing the problem.

I excluded the page with the form on it in functions.php, example code below

add_filter('autoptimize_filter_noptimize','noptimize_contact',10,0);
function noptimize_contact() {
	if (strpos($_SERVER['REQUEST_URI'],'contact-me')!==false) {
		return true;
	} else {
		return false;
	}
}

I think Autoptimize can’t optimise 3rd party hosted JS/ CSS - loaded from Google in this case.

#1324941

Ah yes, those optimizations can be used with Toolset but you have to exclude a few scripts, amongst them the re-captcha scripts but also codemirror (for Toolset FORMS date fields and others to work fine)
https://toolset.com/faq/how-to-use-optimization-plugins-with-toolset/

I had forgotten to ask the Documentation guys to add Recaptcha when I asked to create that DOC.
However, I've asked now to add it, based on your and several other reports in the past.

#1832877

I had the same issue, which was also caused by Autoptimize. The Recaptcha (at least Recaptcha v2) script to exclude in Autoptimize is /recaptcha/api.js.