Hi
I have managed to setup a form and it's working (almost) fine.
The form has a checkbox where the user can decide if a resulting email is sent to his email-address or not.
No matter what the status of checkbox the email is always sent.
Here's the code I use in OnSubmit-before:
So, if check0 is NOT checked I disable template 2 (at least this is my intention :-))
Any ideas on why the email is sent eventhough template is disabled?
Thanks
RichardC
I have managed to setup a form and it's working (almost) fine.
The form has a checkbox where the user can decide if a resulting email is sent to his email-address or not.
No matter what the status of checkbox the email is always sent.
Here's the code I use in OnSubmit-before:
<?php
$emails_2 = array('Info'=>'info@mail.tld', 'Sales'=>'sales@mail.tld', 'Purchasing'=>'Purchasing@mail.tld', 'Buchhaltung'=>'Buchhaltung@mail.tld');
/*
$MyForm =& CFChronoForm::getInstance('myContactForm');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['my_recipient']]);
*/
$_POST['datecreated_EN'] = date("l , F j, Y");
$_POST['timecreated_EN'] = date("h:i A");
$_POST['datecreated_DE'] = strftime("%A, %d. %B %Y");
$_POST['timecreated_DE'] = strftime("%H:%M Uhr");
$_POST['my_mail2'] = $emails_2[$_POST['my_recipient']];
$_POST['my_fromname'] = "my from name (" . $_POST['my_recipient'] . ")";
$_POST['visitor_fullname'] = $_POST['visitor_firstname'] . " " . $_POST['visitor_name'];
$_POST['subject'] = $_POST['visitor_subject'] . " (via our Website)";
$MyForm =& CFChronoForm::getInstance('myContactForm');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$check0 = JRequest::getString('check0', '', 'post');
if ( ! $check0 ) {
$MyFormEmails->setEmailData(2, 'enabled', false);
$_POST['text_mailsent2you'] = "no email copy requested";
} else {
$_POST['text_mailsent2you'] = " a copy of this email was sent to " . $_POST['visitor_email'];
}
$sess =& JFactory::getSession();
$sess->set('my_mail2', $_POST['my_mail2']);
$sess->set('text_mailsent2you', $_POST['text_mailsent2you']);
?>
So, if check0 is NOT checked I disable template 2 (at least this is my intention :-))
Any ideas on why the email is sent eventhough template is disabled?
Thanks
RichardC