I need to be able to send an email to someone who is selected from a dropdown list. I made a new extension that uses the “freeform_module_insert_begin” hook. I’m able to see all the contents of the submitted form using the extension. What I would like to do is take the contents of one field (which is an email) and send that person an email using the correct template. I know I can’t dynamically populate the “notify” parameter, so I thought I might be able to put a generic address in that parameter, and then send the email again to the “real” address I need the form to go to using the hook.
Here is the function in my hook:
function freeform_module_insert_begin ($data)
{
echo '<pre>';
print_r($data);
echo '</pre>';
exit;
}
That shows me the contents of all my fields then exits. I was using that for testing. Here is an abbreviated version of the output from that:
Array
(
[author_id] => 1
[group_id] => 1
[ip_address] => 90.100.100.100
[entry_date] => 1216326548
[edit_date] => 1216326548
[status] => open
[form_name] => contactForm
[salescontact] => salesguy@mycompany.com
[fullname] => John Schmo
[company] => Schmo, Inc.
[email] => john@schmo.com
[phone1] => 000 123 4578
[comments] => Call me asap, please.
)
I want to change it to this:
function freeform_module_insert_begin ($data)
{
if ($data['form_name']=='contactForm') {
var $salesEmail = $data['salescontact'];
// the sales email in this case is salesguy@mycompany.com
// how the heck do i email them the contents of $data, preferably using a certain template?
}
}
I want to email the salescontact (which was selected from a dropdown) before inserting the data into the DB. Can I just rip out the email parts from mod.freeform.php and put them here? (Approximately line 1042 or 1236).
Any help with this greatly appreciated.
