Webform mail template override - total customization

I wanted to make a override of webform mail template, so I can send custom data to paying and non paying partners on my site. As I am using ZEN subtheme, I need to put all the the template in obviously template folder of subtheme, not a root one. Find a default template file in webform module webform-mail.tpl.php and make it something like webform-mail-174.tpl.php, 174 being a nid of your webform. So in order to make this override work. You also need to choose carefully in your webform UI. So under webform edit, you choose email tab and go to your email settings node/174/webform/emails/1 should be url of your first email and there you edit template settings. You can make your custom template there, but without any PHP, just using tokens and that is not what I want to achive here, so in order to make this override work, you need to set template to default as this is crucial and many tutorials online don't mention this. After that you can do overrides in your template file.

What I did here is make IF statement, to send real data to my paying customers, and blurred out data to others.


$dentists = array("marko@marko.hr", "other_email@dentist.com");
if (in_array($submission->data[10]['value'][0] , $dentists)) {
print '<p>Nome: '. $submission->data[1]['value'][0].'<br>';
print 'E-mail: '. $submission->data[2]['value'][0].'<br>';
print 'Cell/Tel: '. $submission->data[3]['value'][0].'<br>';
print 'Problema o domanda: '. $submission->data[4]['value'][0].'</p>';

} else {
print '<p>Nome: '. $submission->data[1]['value'][0].'<br>';
print 'E-mail: '. substr( $submission->data[2]['value'][0], 0, strpos($submission->data[2]['value'][0], '@')).'@******<br>';
print 'Cell/Tel: **** ****'.'<br>';
print 'Problema o domanda: '. $submission->data[4]['value'][0].'</p>';