Support » Plugin: Invisible reCaptcha for WordPress » auto detect language not working

  • Resolved raykaii


    it seams that when the Challenge Language option is on Automatically detect it only gives it in English.

    i have a multilingual wp website in French and in English using WPML

    If i go on my French language page i still get the reCaptcha in English and even if i set my web browser to French.

    BTW thx for doing this plugin FREE with all thos option WP needed a good plugin like this 🙂 hope it stays like this.

    Keep up the good work!

    • This topic was modified 3 years, 1 month ago by raykaii.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author MihChe


    Hi @raykaii,
    The Language Detection is automatically handled by Google (based on browser settings) and there is nothing I can do.
    I was also reading several forums posts and it seems to be a common issue.

    In this case, all I can do is to provide a hook to programmatically change the language code.

    Please let me know if you or anybody else is interested in this solution and I’ll implement it.


    i would love it if it would work. dont know how hook work tho… but i need it to switch language when ppl are in an other language other then English.

    thx for your time.

    Plugin Author MihChe


    I will add the hook and I’ll post some examples of how to use it.

    ok thx 🙂

    Plugin Author MihChe



    Let’s try this to change the language code based on WPML

    add_filter('google_invre_language_code', function ($languageCode){
    	return defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : $languageCode;

    Please let me know




    ok i can try it where should i add the code ?

    Plugin Author MihChe


    In your child theme you should have the functions.php file.
    If you do not have a child theme, you can add it directly to theme functions.php file.
    Let me know,


    Just had the same problem and added the filter (though it’s google_invre_language_code_filter and not google_invre_language_code).

    You could add another option to the dropdown language that could be “Use wordpress language” and where we wouldn’t need to add the filter function to obtain the same results.

    Thanks for the work!

    as says the post above the correct code is:

    //  Invisible reCaptcha change language based on WPML
    add_filter('google_invre_language_code_filter', function ($languageCode){
    	return defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : $languageCode;

    would be nice to have this code in the plugin as an extra option in the drop-down language that could be “Use WPML language”

    Thanks for the plugin, but would be nice if we could avoid it.

    For example, here’s code that does not depend on the plugin (WPML), just uses WordPress functions:

     * Google recaptcha has a bug, does not automatically handle language and ignores
     * WordPress header which looks like this: <html lang="fr-CA" ...>
     * So have to add hl=<lang code> to the API call:
     *<language code>
     * Use the Invisible Recaptcha plugin hook to insert that, based on standard
     * WordPress functions.
    add_filter('google_invre_language_code_filter', function ($languageCode){
        $languageCode = get_bloginfo( 'language' ); // 'en-US', 'fr-CA', etc
        return $languageCode;

    [Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]

    • This reply was modified 2 years, 5 months ago by bdbrown.
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘auto detect language not working’ is closed to new replies.