Set-up – customized message for the user

NinaB 24 Jul, 2016
Hi Bob
I have made a customized message for the user, which the user receives after having filled out a form. I would appreciate if the following was possible:

1) When the user places a check mark at a not obligatory checkbox, then the message for the user says 1. Is it not possible to change the 1 to a yes (in Danish ja)?

2) I have attached an event to two out of three possibilities in the radio button design. The events are different so I have made two single checkboxes for each event. My question is whether it is possible – eventually by some coding – ONLY to send a message which complies with the user’s choice in the mail for the user. This means, naturally, that the user who places a check mark at the radio button with no event should not receive any event message.

Thanks and best regards
Nina Balslev
GreyHead 24 Jul, 2016
Hi Nina,

For 1. please see this FAQ

For 2. you can use a Custom Code action to build content to be included in the Email template
<?php
$form->data['paragraph_1'] = '';
if ( $form->data['radio1'] == 'yes' ) {
  $form->data['paragraph_1'] = "<div>Thank you for requesting our new CD, it will be mailed to you shortly.</div>";
}
?>

Then include {paragraph_1} in the Email template.

Note: this is a simple example, you can have more complex code and include values from the form data.

Bob
NinaB 25 Jul, 2016
Thanks Bob

Regarding my first question I have read your FAQ closely and I can follow your explanation to some extent. Anyhow, I do not quite know how to convert it into practice regarding my problem with converting the 1 to a JA?

Regarding my second question then I will try to see whether a coding dummy like me is able to implement your suggested coding into practice.

Wish you a nice and sunny day

Best regards

Nina Balslev
GreyHead 25 Jul, 2016
Hi Nina,

In the CheckBox element set the Field Value to Ja (the default value is 1).

If you want to show Nej when the box ix not checked, then scroll down and set Enable Ghost to Yes and add Nej to the Ghost Value box.

Bob
NinaB 25 Jul, 2016
Hi Bob

With your new explanation I have now succeed in converting the 1 into a JA. Thanks

Being a coding dummy I have not had this succes with my second question. I have not changed anything in your coding, just copy pasted it into the relevant template in order to see what it looked like when the user received the mail. Unfortunately, the customer received the pure coding.

My Html coding is as follows

<h3> Hej {Navn}</h3>
<h3>Vi takker for din henvendelse via Jobportal Sydsjælland, som vi snarest vil besvare. Nedenstående får du en udskrift af din henvendelse</h3>
<p> </p>
<table>
<tbody>
<tr>
<td>Du er:</td>
<td>{radio21}</td>
</tr>
<tr>
<td>Ønsker du at blive registreret?</td>
<td>{Tjekboks_arbejdsgivere}</td>
</tr>
<tr>
<td>Ønsker du at blive registreret</td>
<td>{Tjekboks_freelance}</td>
</tr>
<tr>
<td>Angiv evt. telefonnr.</td>
<td>{Telefonnr}</td>
</tr>
<tr>
<td>skriv din Email</td>
<td>{Mail}</td>
</tr>
<tr>
<td>Er du interesseret i at modtage vores nyhedsbrev?</td>
<td>{Nyhedsbrev}</td>
</tr>
<tr>
<td>Hvad drejer din hen - vendelse sig om?</td>
<td>{Emne}</td>
</tr>
<tr>
<td>Uddyb din henvendelse</td>
<td>{Uddyb}</td>
</tr>
</tbody>
</table>



In this case the value of the users check mark, namely
<tr>
<td>Ønsker du at blive registreret?</td>
<td>{Tjekboks_arbejdsgivere}</td>
</tr>


should have been converted into the mail received by the user.

Please find below the content of the mail:

Hej Ole Olsen

Vi takker for din henvendelse via Jobportal Sydsjælland, som vi snarest vil besvare. Nedenstående får du en udskrift af din henvendelse

 

Du er:	Arbejdsgiver
Ønsker du at blive registreret?	1
Ønsker du at blive registreret	
Angiv evt. telefonnr.	29993486
skriv din Email	balslevnina@gmail.com
Er du interesseret i at modtage vores nyhedsbrev?	Ja tak, jeg vil gerne modtage nyhedsbrevet.
Hvad drejer din hen - vendelse sig om?	Test Bob 2
Uddyb din henvendelse	Test af Bobs kodning 2
<?php

$form->data['paragraph_1'] = '';

if ( $form->data['radio1'] == 'yes' ) {

  $form->data['paragraph_1'] = "<div>Thank you for requesting our new CD, it will be mailed to you shortly.</div>";

?>}

Could you please inform me how to insert your PHP coding in the HTML coding to get it to function?

Thanks and best regards

Nina Balslev
GreyHead 25 Jul, 2016
Hi NinaB,

Please drag a Custom Code action into the form On Submit event and drag it up before the Email action. Add the PHP code in the Custom Code action. Then include {paragraph_1} in the Email template.

Please then drag a Debugger action into the On Submit event, then submit the form and post the debug - including the 'dummy emails' results here.

Bob
NinaB 27 Jul, 2016
Hi Bob

Is this what you are asking for regarding the debug?
Data Array
Array
(
    [chronoform] => Kontaktformular
    [event] => submit
    [Navn] => Svend Svendsen
    [radio21] => Arbejdsgiver
    [Telefonnr] => 29
    [Mail] => balslevnina@gmail.com
    [Nyhedsbrev] => Ja tak, jeg vil gerne modtage nyhedsbrevet.
    [Emne] => test PHP
    [Uddyb] => Tester igen PHP
    [captcha] => EN4FX
    [send] => send
    [Itemid] => 185
    [Kontaktformular] => 
    [ip_address] => 109.57.82.210
)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
    [0] => Array
        (
            [Email] => Array
                (
                    [0] => An email with the details below was sent successfully:
                    [1] => To:nina@seo-webdesign.dk
                    [2] => Subject:Henvendelse fra kontaktformular
                    [3] => From name:Kontaktformular
                    [4] => From email:
                    [5] => CC:
                    [6] => BCC:
                    [7] => Reply name:
                    [8] => Reply email:
                    [9] => Attachments:
                    [10] => Array
                        (
                        )

                    [11] => Body:
<table>
<tr><td>C</td><td></td></tr>
<tr><td>Skriv dit navn</td><td>Svend Svendsen</td></tr>
<tr><td>Er du:</td><td>Arbejdsgiver</td></tr>
<tr><td>C</td><td></td></tr>
<tr><td>Ønsker du at blive registreret?</td><td></td></tr>
<tr><td>Ønsker du at blive registreret</td><td></td></tr>
<tr><td>Angiv evt. telefonnr.</td><td>29</td></tr>
<tr><td>skriv din Email</td><td>balslevnina@gmail.com</td></tr>
<tr><td>Er du interesseret i at modtage vores nyhedsbrev?</td><td>Ja tak, jeg vil gerne modtage nyhedsbrevet.</td></tr>
<tr><td>Hvad drejer din hen - vendelse sig om?</td><td>test PHP</td></tr>
<tr><td>Uddyb din henvendelse</td><td>Tester igen PHP</td></tr>
<tr><td>Skriv koden for at undgå spam</td><td>EN4FX</td></tr>
<tr><td></td><td>EN4FX</td></tr>
</table><br /><br />IP: 109.57.82.210
                )

        )

    [1] => Array
        (
            [Email] => Array
                (
                    [0] => An email with the details below was sent successfully:
                    [1] => To:balslevnina@gmail.com
                    [2] => Subject:Din henvendelse til Jobportal Sydsjælland via kontaktformularen
                    [3] => From name:Jobportal Sydsjælland
                    [4] => From email:nina@seo-webdesign.dk
                    [5] => CC:
                    [6] => BCC:
                    [7] => Reply name:
                    [8] => Reply email:
                    [9] => Attachments:
                    [10] => Array
                        (
                        )

                    [11] => Body:
<h3> Hej Svend Svendsen</h3>
<h3>Vi takker for din henvendelse via Jobportal Sydsjælland, som vi snarest vil besvare. Nedenstående får du en udskrift af din henvendelse</h3>
<p> </p>
<table>
<tbody>
<tr>
<td>Du er:</td>
<td>Arbejdsgiver</td>
</tr>

<tr>
<td>Ønsker du at blive registreret?</td>
<td></td>
</tr>
<tr>
<td>Ønsker du at blive registreret</td>
<td></td>
</tr>
<tr>
<td>Angiv evt. telefonnr.</td>
<td>29</td>
</tr>
<tr>
<td>skriv din Email</td>
<td>balslevnina@gmail.com</td>
</tr>
<tr>
<td>Er du interesseret i at modtage vores nyhedsbrev?</td>
<td>Ja tak, jeg vil gerne modtage nyhedsbrevet.</td>
</tr>
<tr>
<td>Hvad drejer din hen - vendelse sig om?</td>
<td>test PHP</td>
</tr>
<tr>
<td>Uddyb din henvendelse</td>
<td>Tester igen PHP</td>
</tr>
</tbody>
</table>
<p><?php</p>
<p>$form->data['paragraph_1'] = '';</p>
<p>if ( $form->data['radio1'] == 'yes' ) {</p>
<p>  $form->data['paragraph_1'] = "<div>Thank you for requesting our new CD, it will be mailed to you shortly.</div>";</p>
<p>}</p>
<p>?></p><br /><br />IP: 109.57.82.210
                )

        )

)



Best regards

Nina Balslev
GreyHead 27 Jul, 2016
Hi Nina,

It looks as if you have the PHP code in the Email template? Please move it to a Custom Code action before the Email action and put {paragraph_1} in the Email template.

Bob
NinaB 27 Jul, 2016
Hi Bob

I have surely made a mistake. Anyhow I do not think that I have made the mentioned mistake. I enclose 3 screen prints which I hope would clearify the problem?

Best regards

Nina Balslev
GreyHead 27 Jul, 2016
Hi Nina,

That needs to be a Custom Code action in the On Submit event on the Setup tab (it looks like you have it in a Custom Code element on the Designer tab).

Bob
NinaB 27 Jul, 2016
Hi Bob

I cannot find the custom code action in the on submit event on the set up tab. Is it because I use the simple set-up mode?

Best regards

Nina Balslev
NinaB 27 Jul, 2016
Hi Bob

I cannot find the custom code action in the on submit event on the set up tab. Is it because I use the simple set-up mode?

Best regards

Nina Balslev
GreyHead 27 Jul, 2016
Hi Nina,

Yes, If you change the Form Type to Advanced in the General tab and save the form you will see all of the actions. Please don't change back again later as you may use changes.

Bob
NinaB 28 Jul, 2016
Hi Bob

I have now changed my form from the simple set-uo mode to the advanced. I do not have any problems in finding the custom code action button on the set-up tab. Anyhow, I still do not know where to find the on submit event on the set up tab?

You also ask me to drag it up before the email action. Is the E-mail action mail 1 for the user?

I enclose three screen shoots showing the set-up part of the form for your information.

Best regards

Nina Balslev
GreyHead 28 Jul, 2016
Hi Nina,

Here's how you add it to the event. When you drop it in it will go to the bottom of the actions in the event. You then need to drag it up before the action where you need to use the result of the custom code as CF runs the actions in sequence.

Bob
This topic is locked and no more replies can be posted.