reCAPTCHA broken: v2 widget doesn’t render, v3 token never generated
-
Hi metforms team,
Submitting a MetForm with reCAPTCHA enabled fails with “Something went wrong. Google captcha token not found.” in MetForm 4.1.4.
v3: badge appears, but the hidden
g-recaptcha-response-v3input is never populated.
v2: the checkbox widget never renders (g-recaptchadiv stays empty,offsetHeight: 0).
Already ruled out: theme switch (Twenty Twenty-Five → Twenty Twenty-Three), deactivating all non-essential plugins, cache flushes, wrong site key / domain mismatch (manualgrecaptcha.execute(sitekey, {action: 'submit'}) from the browser console returns a valid token on the same page).In
metform/public/assets/js/app.js, therenderReCaptchamethod that callsgrecaptcha.render()(v2) orgrecaptcha.execute()(v3) is bound viawindow.onload = function(e) { t.renderReCaptcha(r, e) }. Since the bundle is enqueued in the footer and arrives after the load event has fired, the handler is never executed.A readyState-safe binding (
if (document.readyState === 'complete') renderReCaptcha(); else window.addEventListener('load', …)) should fix both cases.Thanks!
You must be logged in to reply to this topic.