Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Chouby

    (@chouby)

    Did you try to hide the language code for the default language in Polylang settings? Thus https://example.com/ should be associated to your default language only.

    Thread Starter jpmonette

    (@jpmonette)

    Yes, I did enable the setting to hide the language when it’s the default one.

    Here are my actual settings (if this can help troubleshoot):
    https://i.imgur.com/9BHon34.png

    Same problem for me (and same settings, Polylang 1.2 beta)

    Thread Starter jpmonette

    (@jpmonette)

    Same problem for me (and same settings, Polylang 1.2 beta)

    I’m using beta too, but I had the same issue previously with stable version.

    Plugin Author Chouby

    (@chouby)

    Sorry. I did not think to this when answering the first time.

    If you click on a link inside your site, there is no redirection. If you are coming from elsewhere, there is a redirection to the last browsed language (so that once the user as chosen his language, he does’nt have to redo his choice each time).

    If you don’t like this, see https://polylang.wordpress.com/documentation/documentation-for-developers/filter-reference/#pll_redirect_home

    It should works the same for stable and beta.

    Thread Starter jpmonette

    (@jpmonette)

    And how am I suppose to enable that? I added that to functions.php in my theme and it doesn’t seem to be working.

    add_filter('pll_redirect_home', 'no_home_redirection');
    function no_home_redirection($redirect) {
    	return false;
    }

    EDIT:

    I added the line in polylang/polylang.php and it seems to be working, no more unwanted redirection. Thanks!

    Plugin Author Chouby

    (@chouby)

    Your modification will be overwritten at plugin update.
    Create a file name my-plugin.php with the code below:

    <?php
    /*
    Plugin name: my custom settings
    */
    
    add_filter('pll_redirect_home', 'no_home_redirection');
    function no_home_redirection($redirect) {
    	return false;
    }

    Upload the file in your plugins directory and activate the plugin.

    Thread Starter jpmonette

    (@jpmonette)

    I replied to fast, it doesn’t seem to be working. I created the custom module you suggested me too and when I go at https://example.ca/en/partners (content in English) and type https://example.ca/partners in the address bar, I am redirected to the English version.

    I have no idea how to fix this behavior…

    Plugin Author Chouby

    (@chouby)

    Maybe what you want can be obtained by just removing the cookie by setting PLL_COOKIE to false

    Thread Starter jpmonette

    (@jpmonette)

    I have this in my custom plugin:

    <?php
    add_filter('pll_redirect_home', 'no_home_redirection');
    function no_home_redirection($redirect) {
    	return false;
    }
    
    define(PLL_COOKIE, false);

    Still doesn’t seem to be working. When I click on the link in the menu to reach the ENglish website, everything turns English and the URL contains “/en/”. If I go back at “https://example.com/&#8221;, I still have everything in English… There’s still a cookie somewhere storing the information.

    Plugin Author Chouby

    (@chouby)

    define(PLL_COOKIE, false);

    will likely not work if you put it in a custom plugin. As described in the doc it must be put either in wp-config.php or in wp-content/polylang/pll-config.php

    Same problem here for me.

    I appreciate the plugin.. but this is kinda a serious problem.
    The ‘wp_redirect’ in choose-lang.php should be revised.. and since users already rely either on URL /lang/ or domain lang.domain.com to serve the right content.. the ‘ppl_language’ cookie should not be used. This turns off both user experience and SEO.

    Hopefully, this can be fixed in later versions. ??

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Prevent redirection using language stored in cookie’ is closed to new replies.