Hello,
Could it be that another plugin is also calling reCaptcha? We expect to see both:
wpcf7-recaptcha-controls script being added to the Source and localized variables after the google-recaptcha script. Neither of these appears in your source code, which leads us to believe that another plugin is also adding in reCaptcha and overriding the Contact Form 7 ReCaptcha script.
We would suggest installing the WordPress Health Check & Troubleshooting plugin. This will allow you to safely disable plugins and revert to a default theme until you narrow down which plugin is conflicting. For more information, we suggest looking over the Health Check documentation regarding Troubleshooting.
Once you know which plugin is causing this conflict, you can reach out to their support to figure out the best solution. Hopefully, the above explanation makes sense. Should you have any questions at all, please reply, and we can assist you further. Have a wonderful rest of your week!
Hello team,
I finally found the problem.
It was not a plugin but a piece of code written in the functions.php (child) concerning “the change the language of recaptcha”.
The code in question is this:
add_action( 'wpcf7_enqueue_scripts', 'custom_recaptcha_enqueue_scripts', 11 );
function custom_recaptcha_enqueue_scripts() {
wp_deregister_script( 'google-recaptcha' );
$hl = 'en-GB';
if (ICL_LANGUAGE_CODE == 'es') $hl = 'es';
if (ICL_LANGUAGE_CODE == 'de') $hl = 'de';
if (ICL_LANGUAGE_CODE == 'it') $hl = 'it';
if (ICL_LANGUAGE_CODE == 'fr') $hl = 'fr';
$url = 'https://www.google.com/recaptcha/api.js';
$url = add_query_arg( array(
'onload' => 'recaptchaCallback',
'render' => 'explicit',
'hl' => $hl ), $url );
wp_register_script( 'google-recaptcha', $url, array(), '2.0', true );
}
if I disable it, the Recaptcha works.
This code has been working for more than two years, so some logic must be changed on other plugins that no longer allow it to work.
Do you have an alternative solution to have the Recaptcha in different languages?
Thank you
Hello,
The reCaptcha script uses the site language by default:
'hl' => esc_attr( get_locale() )
It looks like ICL_LANGUAGE_CODE is from WPML. You may be able to use the [locale filter hook](https://developer.ww.wp.xz.cn/reference/hooks/locale/) to supply get_locale() with a different value.
Looking at that script, it does seem fine. We enqueue at priority 9, yours enqueue at priority 11, so it should override ours. We also recommend reaching out to WPML to see what they suggest.