String length and e-mail template

Compare a form field value in a ChronoForms email template.

Overview

The issue occurs when using placeholder syntax like {profil} directly in PHP code, which is not interpreted correctly.
Instead of the placeholder, access the form data array directly using the correct PHP variable structure to perform the comparison.

Answered
na nag 21 Oct, 2015
Hi,

I'd like to make a PHP condition in my email template but the string length is strange...
<?php
var_dump('atelier');
// string(7) "atelier" : OK

var_dump('{profil}');
// string(8) "atelier" : strange!

var_dump('{profil}' == 'atelier');
// bool(false)
?>

What can I do ?
Gr GreyHead 21 Oct, 2015
Hi nag,

Sorry, I have no idea what your question is ;-(

What exactly are you trying to do?

Bob
na nag 22 Oct, 2015
Sorry, my question wasn't clear enough.

Here's a test:
<?php
if ('{profil}' == 'atelier') {
  echo 'yes';
} else {
  echo 'no';
}
?>

This code displays "no". I want it to display "yes".
Gr GreyHead 22 Oct, 2015
Answer
Hi nag,

The {profile} syntax won't work in PHP, please try
if ( $form->data['profile'] == 'atelier' ) {

Bob
na nag 22 Oct, 2015
It works now. Thank you !
This topic is locked and no more replies can be posted.