[feature request] craft different email bodies for "to" recipient and "copysender" recipient.
Feature request: to be able to craft different email bodies for contact form recipient and “copysender” recipient.
Use case: you may want to have some hidden/secret fields on your contact form message and only include them on the email sent to the contact form recipient, while excluding them from the “copysender” recipient. Or maybe you want to add some extra message for the “copysender” recipient so to explain him why is he receiving a copy of the email or whatever.
I thought that testing for copysender value inside body_form could be a solution, but I checked the plugin source code and it seems that the $msg payload is the same for both messages.
Thanks.
You can do this by hooking into zemcontact.deliver.
If I'm not missing something, this should do the trick.
register_callback('yab_send_cc', 'zemcontact.deliver');
/*
* use <txp:zem_contact_secret name="yab_send_cc" value="email_body_form" /> in a
* zem_contact_form to send a CC-Mail, where value is txp form as mail body template
*/
function yab_send_cc($step, $pre, $payload)
{
global $zem_contact_values;
$flags = array('yab_send_cc');
extract($payload);
// handle copysender and plugin flag
if ($pre === 'copysender' and isset($fields['yab_send_cc']))
{
$body = parse_form($zem_contact_values['yab_send_cc']);
foreach($flags as $flag)
{
unset($fields[$flag]);
}
if (zem_contact_deliver($to, $subject, $body, $headers, $fields, array('isCopy' => false)))
{
return 'zemcontact.skip';
}
}