I'd like to include the cf_id of the form submission just inserted into the database. I've learned that you can create new variables accessible in email templates {new_var} by assigning them to $_POST[new_var] in the "On Submit code - before sending email:" section (with the exception of $_POST['cf_id'] - that disables the data from being saved!).
But
One workaround I have found is:
and then of course referencing {new_id} in the email template.
This hack works as long as the insert is successful, but pretty weak IMHO. The fact that this works suggests that this code in the "On Submit before sending email" section is executed before the email is sent, AND before the data is saved. Is there any hook that's between saving and sending?
Is there any other more reliable way to send the insert_id ( insertid() ) of the submitted data's row in the email?
I have looked through the forums for a couple hours, but if I overlooked something, a link would be greatly appreciated.🙂
But
<?php $db =& JFactory::getDBO(); $_POST['new_id'] = $db->insertid(); ?>
doesn't work. One workaround I have found is:
<?php
$sql = "SELECT MAX(cf_id) + 1 AS id FROM jos_chronoforms_mytable";
$db->setQuery($sql);
$result = $db->loadObject();
$_POST['new_id'] = $result->id;
?>
and then of course referencing {new_id} in the email template.
This hack works as long as the insert is successful, but pretty weak IMHO. The fact that this works suggests that this code in the "On Submit before sending email" section is executed before the email is sent, AND before the data is saved. Is there any hook that's between saving and sending?
Is there any other more reliable way to send the insert_id ( insertid() ) of the submitted data's row in the email?
I have looked through the forums for a couple hours, but if I overlooked something, a link would be greatly appreciated.🙂