0

I have been trying to create a contact form auto-responder with a select list, one of the main sources I used is this

The only change I did to his code is obviously the variables and changed

add_action( 'wpcf7_mail_sent', 'contact_form_autoresponders' ); 

to

add_action( 'wpcf7_mail_sent', array($this, 'contact_form_autoresponders' ), 5);

I have been trying to create an automated email responder for any options out of the selected 'select' menu.

I have been importing another file.php which contains all the string variables I need with "<<

all the variables in file.php looks like this:

$some_variable =<<<EOT multiple 
                    lines 
                     here
 EOT;

Since My email responses are in Hebrew I want the responded mail to be sent right to left and I am looking all over the place for a way to align my string to the right and add some URL marks and can't find it.

I tried adding this to the Headers and String head and it didn't work out for me

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" 
direction="rtl">

Any help would be appreciated.

Yoni hodeffi
  • 103
  • 2
  • 8
  • if you are asking in context of mail message, try this: https://stackoverflow.com/a/20680966/2962442 – Kamil Karkus Dec 06 '17 at 14:52
  • in your modification, you replace the second argument being passed which is a `STRING` with an `ARRAY`. Is the add_action function prepared to deal with that? – coderodour Dec 06 '17 at 14:52
  • @kmlnvm I'm asking in the context of a String that needs to be translated into an e-mail – Yoni hodeffi Dec 06 '17 at 14:58
  • @Yonihodeffi it depends on your IDE I think, e.g.: https://www.jetbrains.com/help/phpstorm/configuring-text-direction.html But remember when you send email to change direction of text in html or css. – Kamil Karkus Dec 06 '17 at 15:01
  • @Yonihodeffi I don't know if rtl will work with english – Kamil Karkus Dec 06 '17 at 15:04
  • @kmlnvm I tried using HTML and it didn't work, I am writing a question here after many many different tries. It's like the mail server completely ignore the fact I am sending him HTML. I know it's plain text by default but I already changed wp_mail to support HTML. – Yoni hodeffi Dec 06 '17 at 15:05
  • @Yonihodeffi please check my answer – Kamil Karkus Dec 06 '17 at 15:08

2 Answers2

0

Replace...

direction="rtl"

with

dir="rtl"

You can find more informations here https://www.w3.org/International/questions/qa-html-dir

Remember to change lang attribute too.

Kamil Karkus
  • 1,283
  • 1
  • 11
  • 29
0

If I understand you correctly, if your file.php included an array of posted object properties (i.e. $this->option1, $this->option2) then the code, based on the link you gave, would look something like:

#our autoresponders function
function contact_form_autoresponders( $contact_form ) {

    if( $contact_form->id==1234 ){ #your contact form ID - you can find this in contact form 7 settings

        #retrieve the details of the form/post
        $submission = WPCF7_Submission::get_instance();
        $posted_data = $submission->get_posted_data();                          

        $msg = array();
        #set autoresponders based on dropdown choice, in an array     
        switch( $this->posteddata){ #your dropdown menu field name
            case 'California':
            $msg+="California email body goes here";
            break;

            case 'Texas':
            $msg+="Texas email body goes here";
            break;

        }
        $msg_str = implode("", $msg);

        #mail it to them
        mail( $posted_data['your-email'], 'Thanks for your enquiry', $msg_str );
    }

}

Note the $msg = array(); as a string array, the $msg += "<multiline string>" for each case that matches a posted query variable, and the $msg_str = implode("", $msg) to make a final string (that may be HTML or non-html).

If you are using a HTML email, aligning the options' values right is a matter of css rules. So your final HTML email would look like:

<html>
<head>
    <style>
        .align-right
        {
            text-align: right;
            direction: rtl;
        }
    </style>
</head>
<body>
...
...
...
<table>
    <tbody>
        <tr>
        <td class="option-name">California</td>
        <td class="option-value align-right">THE MULTILINE STRING</td>
        </tr>
        <tr>
        <td class="option-name">Texas</td>
        <td class="option-value align-right">THE MULTILINE STRING</td>
        </tr>
    </tbody>
</table>
</html>
L. J.
  • 136
  • 1
  • 4