Forums

Conditionnal email in V4

schlogo 14 Dec, 2011
Hello

Working with V3, i was using the following code to enable and disable emails . I wanted to use the same piece of code in V4 but I can't get it to work. I get a blank page and the email is not sent.

Would someone know what i need to change ?

Tks !

 <?php
$MyForm =& CFChronoForm::getInstance('diagmanagement');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);

$mailtype = $_POST['mailtype'];

if($mailtype  == "1") 
{

$MyFormEmails->setEmailData(1, 'enabled', '0');//enable  email 1

$MyFormEmails->setEmailData(2, 'enabled', '1');//enable  email 2
}
else
{

$MyFormEmails->setEmailData(1, 'enabled', '1');//disable email 1

$MyFormEmails->setEmailData(2, 'enabled', '0');//disable email 2
}
?> 
GreyHead 15 Dec, 2011
Hi schlogo ,

All of this code has chaned in CFv4. If you use my Email [GH] action then it has a built in 'condition' box that you an use to turn individual emails on and off. That might be the easiest answer here.

Bob

PS Otherwise I'm working on a 'Switcher' action that lets you activate different events depending on the from results. But that seems more than you need here.
schlogo 16 Dec, 2011
Hello

Thanks for your help, i think it s exactly what i need

O
Max_admin 30 Dec, 2011
Just a note, starting from V4 RC3.0, you can dynamically enable/disable ANY action with this code:


<?php
$form->set('ACTION_ID', 'enabled', 1);
?>


The one should be set to "0" if you want to "Disable".

And the "ACTION_ID" is something like: "email_x", where "x" is the action order number shown in red in the wizard.

Regards,
Max
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.