[Support request] GP Premium Polylang and CF7 reCAPTCHA language

Home Forums Support GP Premium Polylang and CF7 reCAPTCHA language

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1098087
    Frans

    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

    #1098141
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You need to add that function using one of these methods: https://docs.generatepress.com/article/adding-php/

    Let us know if you need more info 🙂

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.