Support » Plugin: Contact Form 7 Polylang Module » Mailtag [_site_url] is not returning the localized homepage URL

  • Resolved swissspaceboy


    I logged this first at Polylang but this is more a contact form problem than Polylang.

    I just find out about this behaviour. The mailtag [_site_url] function always returns to your default homepage, and not the active homepage.

    * default English website as configured in WP:
    * French website is found here:

    When sending a french email form using [_site_url], it returns me the English homepage url like

    This is wrong and it should be

    My pll settings:
    * The language is set from the directory name in pretty permalinks
    * Hide URL language information for default language
    * Remove /language/ in pretty permalinks
    * The front page url contains the language code instead of the page name or page id

    So my french emails display the english homepage URL 🙁

    This is the answer from Polylang:

    This is not a Polylang bug.
    site_url() is allways returning the site url from option table. In your case you can try to use pll_home_url in conjunction with pll_current_language (

    So when using the mailtag [_site_url], you should use pll_home_url + pll_current_language. Correct ?



Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Aurovrata Venet


    Bonjour Didier,

    en effet il y a de l’eau dans le gas la!

    This is a Contact Form 7 bug and should be raised in that forum. However, a quick inspection of the cf7 code reveals that its author is using the get_bloginfo('url') to return the site url. However, he has provided a work around… which I have decided to add as part of the functionality of the plugin. So I am just pushing out v2.2.0 to fix this very problem. Let me know if it works.

    Hi Aurovrata !

    I updated the plugin but it doesn’t seem to work. Using [_site_url] in my French contact form, I still get the English (default) home page.

    Do I need to save the form again or is this mailtag evaluated during runtime/execution?

    Thanks for your support.


    Plugin Author Aurovrata Venet


    That’s because site_url() is not the same as home_url(). If you want to get your french home url, you need to use the function home_url().

    Furthermore, Polylang plugin only filters the home_url link on the frontend and not the backend, and since the cf7 mail tags are built on the backend (hooked on admin filters) it is not able to get access to the filter urls.

    I will try to implement an alternative approach to this problem and introduce instead a [_home_url] mail tag which will use the filtered polylang value.

    Plugin Author Aurovrata Venet


    try it with v2.3

    Bingo !

    By using the mail tag [_home_url], the correct home page link is returned respecting the language. The fix is validated.

    Super great ! You are the man 🙂

    Many thanks & grand merci !


    PS: I will leave a good tip on the table..

    • This reply was modified 2 years, 3 months ago by swissspaceboy.
    Plugin Author Aurovrata Venet


    Thank Didier for the kind words!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Mailtag [_site_url] is not returning the localized homepage URL’ is closed to new replies.