Conditional email - date plugin

jo-ka

Member
Hello.

I' have a conditional email form plugin, which sends an email everytime one of the form fields is updated with new values. Something like this and is working for all elements except date element.

So, this works:

upload_2019-7-6_1-10-59.png

But if the element is a date element, the email is sent everytime, even though the value is not changed. The mail body then has no value for the date, but the email is sent anyway.

So, for the date plugin, I have this condition:

upload_2019-7-6_1-13-54.png

I've tried with and without _raw for both fields but with no avail.

Also, the value on the database does'nt change at all, as the time value is allways set like 00:00:00.

The element is set for Local Time as the site is only used locally.

upload_2019-7-6_1-17-18.png

What can possibly be wrong?
 
Check with var_dump(...);exit; what you really get.
I think for the date element (and also dbjoins etc) $origData is an array.
 
Yes, it's an array in deed.
So how shall I use it here?

Tried like this, but the result is the same:

PHP:
$origData[0]["fab_juizes___data_exame_medico"];

If I use it like this, nothing happens:

PHP:
$origData[0]->["fab_juizes___data_exame_medico"];
 
$origData[...][0]
But for comparing it must be exactly the same date/time format so maybe you have to do additionally some string handling.

Gesendet von meinem SM-G930F mit Tapatalk
 
So, I've made this change:
PHP:
return '{fab_juizes___data_exame_medico}' != $origData["fab_juizes___data_exame_medico"][0];
but sitll no luck.

Where can I put the
PHP:
var_dump(...);exit;
code, so I can check what's beeing compared?
 
Before the return do
var_dump('{fab_juizes___data_exame_medico}',$origData["fab_juizes___data_exame_medico"][0]);exit;
 
Hmm, I can't replicate this. Also odd that your main form placeholder is empty as well.

Can you just do ...

var_dump($origData);exit;

... and lets see the whole array.

-- hugh
 
OK, I've ended up doing this:
PHP:
//first validade if the form element is empty or null
$aux='{fab_juizes___data_exame_medico_raw}' == "" ? "0000-00-00 00:00:00" : '{fab_juizes___data_exame_medico_raw}';

//then, send the email only if the new value and original value are different
return $aux != $origData["fab_juizes___data_exame_medico"];

Working as wished.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top