Quick tip: WordPress – How to make Contact Form 7 working with qTranslate

On my recent project I had to create multilingual site and we decided to add multiple languages using qTranslate plugin.

The site of course has “Contact us” page and we decided to use Contact Form 7 plugin because it’s rich and flexible plugin for creating contact forms.

So far so good, but we detected that when the language is different than the default one, the form submission is redirecting to the default language page and because the forms are different they didn’t handle properly the errors as well as the thankyou message.

The solution is very simple. Go and add this code in functions.php under your theme folder (if you don’ have such file, create it).

add_filter('wpcf7_form_action_url', 'wpcf7_action_url');

function wpcf7_action_url(){


        return qtrans_convertURL($_SERVER["REQUEST_URI"]);


    return $_SERVER["REQUEST_URI"];


The short explanation: It create a filter which is applied the the Contact Form 7 action in the form tag. Using the qtrans_convertURL() the Request URI will be converted and it will use the currently selected language. I’ve added a validation if the qtrans_convertURL if some day the plugin is disabled.

15 thoughts on “Quick tip: WordPress – How to make Contact Form 7 working with qTranslate

  1. im79

    if you want to use it on a https secured connection, qtrans_convertURL($_SERVER[“REQUEST_URI”]) returns a link with “http://”. So Contact Form 7 has a wrong “action” and you will not get an Ajax response.

    First you should check if there is an https secured connection:

    $sendtourl = qtrans_convertURL($_SERVER[“REQUEST_URI”]);
    if(isset($_SERVER[‘HTTPS’]) && ($_SERVER[‘HTTPS’] == ‘1’ || $_SERVER[‘HTTPS’] == ‘on’))$sendtourl = preg_replace(‘#^http://#’,’https://’, $sendtourl);
    return $sendtourl;

  2. Giuliano

    Instead of of REQUEST_URI, I had to use $url . The version of cf7 I’m dealing with adds an extra “#code” at the end of the submission url…

    add_filter(‘wpcf7_form_action_url’, ‘wpcf7_action_url’);
    function wpcf7_action_url($url){
    return qtrans_convertURL($url);
    return $url;

  3. clemence

    Did you install somme kind of extra plugin or new function in functions.php in order to define different languages to the contact form? Because I used your code but it does not work. Can you give us more details?

    Also with the explanation of the code, I understood that you created as much contact forms as languages used by the website. I mean, if my website is in french and english, I have to have 2 forms, one in french the other in english. Is that right?

  4. Nik Chankov Post author

    as the title says it’s qTranslate 🙂 as well as the code which is in the post. It’s 1 year old post and plugins which I’ve used could be changed and my changes could be insufficient.

  5. clemence

    Yes, that’s right! I’ve seen so many articles about the subject this morning…. I new your publication was interesting, and once I’ve read it again, I forgot to see the title…

    But what about the contact form?
    Do I have to create different in order to make your code work?


  6. Ale

    Hi, I use conatct form 3.34 on WP 3.4.

    I write the code in functions.php.

    How and where to call the function:

    add_filter(‘wpcf7_form_action_url’, ‘wpcf7_action_url’);

    function wpcf7_action_url(){


    return qtrans_convertURL($_SERVER[“REQUEST_URI”]);


    return $_SERVER[“REQUEST_URI”];


    in contact_form.php???

    Thank you 🙂 ?

  7. Nik Chankov Post author

    That’s what this line do:
    add_filter(‘wpcf7_form_action_url’, ‘wpcf7_action_url’);

    attach the function to the wpcf7 form. Bear in mind that both plugins probably evolved and the code probably is not working any more.

Leave a Reply

Your email address will not be published. Required fields are marked *