Buy Now
Sign in

Adding some php in email body

micker , January 11 2022, 09:31
M
micker 118
January 11 2022, 09:31 #397717
hello i use an old chronoform i know but i can't change
is it possible to add php code in email template to change some information on fly ?
regards
GreyHead 65
January 12 2022, 18:24 #397731
Hi micker,You can use PHP in a Custom PHP action before the Email action to build custom for data that you can
then include in the email.
Bob
If you'd like to buy me a coffee or two, thank you very much
M
micker 118
January 12 2022, 18:36 #397733
cool did you have a small tuto or documentation about this ?
for now i have a field {extensions}
and i want to create some small php check to return good result in email ?
regards
GreyHead 65
January 12 2022, 18:44 #397734
Hi micker,
What exactly do you need to do?
Bob
If you'd like to buy me a coffee or two, thank you very much
M
micker 118
January 13 2022, 07:36 #397735
hi
i have field (checkbox)
{extensions}
in email its return some arrays with value
i want to convert some value in readable value for recipeir like
$myvlaue = data in extension field;
if (!empty ($myvlaue){
if ($myvlaue == 1);
echo = 'My texte dljflmsdgjdmfgjmlfgj in body email';
} elseif ($myvlaue == 2){
echo = 'My texte 2 dljflmsdgjdmfgjmlfgj in body email';
}
etc ....
i hope its more clear
GreyHead 65
January 13 2022, 10:41 #397736
Hi micker,
Please check the CFv5 manual if you have a copy - I think the answer is there.
You can use Custom PHP something like this:
<?php
if ( !empty ($form-data['myvalue']) ) {
if ( $form-data['myvalue'] == 1 ) {
$form->data['mytext'] = 'My texte dljflmsdgjdmfgjmlfgj in body email';
. . .
?>
Then the value of mytext will be added to the form data and can be used in your email.
Bob
If you'd like to buy me a coffee or two, thank you very much
M
micker 118
January 14 2022, 08:10 #397745
ok just to be sure
1 i create a custom code block
2 drag and drop in on submit event
and my code ?
exemple
<?php
if ( !empty ($form-data['extensions']) ) {
$form->data['extensions'] = $form->data['extensions'];
}else {
$form->data['extensions']="pas d'extensions";
}
?>
my user want a value in his email if $form-data['extensions'] is empty
GreyHead 65
January 14 2022, 15:49 #397746
Hi micker,
You can simplify the code a little bit:
<?php
if ( empty ($form-data['extensions']) ) {
$form->data['extensions'] = "pas d'extensions";
}
?>
Otherwise it looks OK to me.
Bob
If you'd like to buy me a coffee or two, thank you very much