Please help Must go to Production today :( - Variables in Email.

Include a dynamically generated variable in a CF email.

Overview

The issue occurs because the variable is set in PHP but not properly integrated into the email content.
Use the 'Alternative data' behavior for the form field to override its value, or set the variable using a PHP action and reference it in the email with the correct placeholder.

Answered
ChronoForms v7
Sw SwingeyP 29 Jan, 2021
Hi I have a problem where a variable on a form is not showing in the email sent on submission.

Can you please help me with this?

The email recipient is set as {user:email} and an email is sent showing all form fields except one called Reference.

The reference is generated like this:

$Reference = $date .$SiteID;

$this->set("EmailReference", $Reference);

On 'page2' I have some code that submits to the database and displays the Reference number. The reference is clearly displayed in the form however it 's value is not included in the email but the empty field is.

Email in settings looks like this:
<?php
echo {$form->data['reference']};
echo {$EmailReference};
//echo '<br>';
?>

Thank you for contacting {site:title}! Our specialists will contact you at the soonest opportunity.
<br><br>
In the meantime, we have received the following details from you:
<br><br>
{email_content}

I have included variables in the top to try and show the variable but nothing. Ideally i'd like it to be part of the {email_content}
Max_admin Max_admin 29 Jan, 2021
Answer
if you want it to be part of the {email_content} then use the "Alternative data" behavior of the field to override the field value, or set the variables with PHP action then use {var:var_name}
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.