Buy Now
Sign in

Custom Code for Email Body is not working

sstiller , December 26 2019, 15:46
S
sstiller 1
December 26 2019, 15:46 #390496
Hi,
I've read the entries for creating cutomized email bodies. I created Custom Code:
<?php
$Email_body = array();
$Email_body = "<p><strong>Liebe(r) {$form->data['name']} </strong> </p>";
$Email_body = "<p></p>";
$Email_body
= "<p>vielen Dank für Ihre Nachricht. Ich werde mich schnellstmöglich mit Ihnen in Verbindung setzen.</p>";
if ( $form->subject['some_input']
) {
$Email_body
= "<p>Label: {$form->subject['some_input']}</p>";
}
if ( $form->which_calendar['some_input']
) {
$Email_body
= "<p>Label: {$form->which_calendar['some_input']}</p>";
}
if ( $form->amount['some_input']
) {
$Email_body
= "<p>Label: {$form->amount['some_input']}</p>";
}
if ( $form->size['some_input']
) {
$Email_body
= "<p>Label: {$form->size['some_input']}</p>";
}
if ( $form->picture['some_input']
) {
$Email_body
= "<p>Label: {$form->picture['some_input']}</p>";
}

$form->data['Email_template'] = implode("\n", $Email_body);
?>
Afterwards I entered {Email_template} in both "Body" sections of email tab "General" and "Auto template", but neither of These Options worked. I got error message that Body text is empty.
GreyHead 64
December 30 2019, 19:06 #390517
Hi sstiller,
Please debug your PHP. You define $Email_body as an array at the beginning, then redefine it as a series of strings each of which writes over the previous value. Please try removing the array line (and the explode at the end) then use .= to extend the string . . .
<?php
$Email_body = "<p><strong>Liebe(r) {$form->data['name']} </strong> </p>";
$Email_body .= "<p></p>";
$Email_body .= "<p>vielen Dank für Ihre Nachricht. Ich werde mich schnellstmöglich mit Ihnen in Verbindung setzen.</p>";
. . .
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
healyhatman 9
December 30 2019, 22:11 #390519
Also in CFv6 you use $this->data('fieldname')
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store