Site logo

Archived topic

GP Premium Polylang and CF7 reCAPTCHA language

1 reply · Started by Frans on December 8, 2019

Viewing posts 1–2 of 2

I have a site in English and French and use the Polylang plugin. It works well, except the language of the CF-reCAPTCHA plugin. I registered at Google's from the Netherlands, so the "I'am not a robot text" is in Dutch. I found this script:

https://stackoverflow.com/questions/46484266/wordpress-polylang-contact-form-7-recaptcha-different-languages

and tried to put it in a GP-Elements hook:

function wptricks24_recaptcha_scripts()
{
    wp_deregister_script('google-recaptcha');

    $url = 'https://www.google.com/recaptcha/api.js';
    $url = add_query_arg(array(
        'onload' => 'recaptchaCallback',
        'render' => 'explicit',
        'hl' => pll_current_language('slug')), $url);
    wp_register_script('google-recaptcha', $url, array(), '2.0', true);
}

add_action('wpcf7_enqueue_scripts', 'wptricks24_recaptcha_scripts', 11);

It does not work: the code appears as text on my site. So I tried:

add_action('wpcf7_enqueue_scripts', 'wptricks24_recaptcha_scripts', 11);
function wptricks24_recaptcha_scripts() { ?>
    wp_deregister_script('google-recaptcha');

    $url = 'https://www.google.com/recaptcha/api.js';
    $url = add_query_arg(array(
        'onload' => 'recaptchaCallback',
        'render' => 'explicit',
        'hl' => pll_current_language('slug')), $url);
    wp_register_script('google-recaptcha', $url, array(), '2.0', true);
<?php}

Then there is an error:
Parse error: syntax error, unexpected '}' in /homepages/6/d729501905/htdocs/clickandbuilds/feamc/wp-content/plugins/gp-premium/elements/class-hooks.php(180) : eval()'d code on line 11

Is it possible to adjust the CF7-reCAPTCHA language to the polylang language using Elements Hook ?

Thanks !

Frans

This archived topic is closed to new replies.