Altering the attachments for E-mails via PHP code for WordPress
If you have a form with a dropdown and you wish to attach a specific file to the E-mails based on the selected dropdown item you can use the below code to achieve this.
Place below code in your child theme functions.php file
You can use the super_before_sending_email_attachments_filter
for admin E-mails and the super_before_sending_email_confirm_attachments_filter
for Confirmation E-mails.
In the below code make sure to replace the your_dropdown_name
with the field name of your dropdown element. Also make sure to correctly map the dropdown values with the corresponding file ID's that are stored on your WordPress site. In the below example they are mapped to the dropdown item value option1
, option2
and option3
.
Last updated