WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Fast And Secure Contact Form] Problem using it with a second language (4 posts)

  1. MASSERRA
    Member
    Posted 2 years ago #

    [Plugin: Fast And Secure Contact Form] Problem using it with a second language
    Hi there!! I tried to see if it was possible to send a message directly to Mike Challis, and maybe it is and I missed, but here it is the problem I encountered and tried to patch.

    I am using Fast And Secure Contact Form to make some registration pages, and the Form2, witch happens to be the one in english, is viewed when, on the page, you choose to be in english (using qTranslate plugin).

    Now, the problem was that the one in english should be working because Fast And Secure Contact Form is using the supposed right way to get a full url (for the action attribute), at least from what I've searched, but its not. It gets redirected to the url without any chosen language and because of that the action of the form can't go through, send the variables and be emailed.

    So I did this in the si-contact-form.php (where the form_action_url variable is being defined):

    <code>
    if ( getenv('HTTPS') == 'on' ) {
    $form_action_url = 'https://';
    } else {
    $form_action_url = 'http://';
    }

    if (qtrans_getLanguage() == 'en') {
    $form_action_url .= $_SERVER['HTTP_HOST']."/en".$_SERVER['REQUEST_URI'];
    } elseif (qtrans_getLanguage() == 'pt') {
    $form_action_url .= $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    }
    </code>

    It resulted well, but it is a patch and whenever I update the plugin I will loose this code and will have to redo it...

    Hope you see this!
    And really thanks for the plugin, its pretty good! Keep up the good work! :)
    Yep!

  2. pinhassi
    Member
    Posted 2 years ago #


  3. pinhassi
    Member
    Posted 2 years ago #

    Hi,
    I have the same problem, thanks for the tip.
    Unfortunately, I wasn't able to fix it because my second language page address looks like:
    http://www.website.com/contact/?lang=en
    and I wasn't able to figure out how to change it (I'm a total ignorant when it comes to php)...

    Would you please try to help me solve this? I don't mind even using coded lines like
    $form_action_url = http://www.website.com/contact/?lang=en

    Thanks!

  4. MASSERRA
    Member
    Posted 2 years ago #

    Hi pinhassi,
    Try to do what I said above, in the plugin file "si-contact-form.php".
    You will find something like this, from what I remember:

    <code>
    if ( getenv('HTTPS') == 'on' ) {
    $form_action_url = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    } else {
    $form_action_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    }
    </code>

    Change it to this...

    <code>
    if ( getenv('HTTPS') == 'on' ) {
    $form_action_url = 'https://';
    } else {
    $form_action_url = 'http://';
    }

    if (qtrans_getLanguage() == 'en') {
    $form_action_url .= $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."?lang=en";
    } elseif (qtrans_getLanguage() == 'pt') {
    $form_action_url .= $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    }
    </code>

    The last part is saying that if the language is 'en' than my form action url will be blah blah blah concatenated with "?lang=en" like you told me it was your url... or else, if it's your original language (you have to change this part 'pt' to your language 'ex'), than it's the original url without the ?lang=ex variable...

    PS: If it doesn't work, when I put "?lang=en", change to "/?lang=en"... because I'm not sure if the $_SERVER['REQUEST_URI'] returns the url with an ending slash...

    Good luck! ;)

Topic Closed

This topic has been closed to new replies.

About this Topic