Add an attachment to emails
You can add a file attachment to your emails by adding the following code to your theme’s functions.php file:
<?php | |
/** | |
* Attach a file to an email | |
* | |
* @param array $attachments | |
* @param WPBS_Email $email | |
* @param WPBS_Form $form | |
* @param WPBS_Calendar $calendar | |
* @param int $booking_id | |
* | |
*/ | |
add_filter('wpbs_form_mailer_attachments', function($attachments, $email, $form, $calendar, $booking_id){ | |
if($email->get('id') == 12){ | |
$attachments[] = '/path/to/your/file.pdf'; | |
} | |
return $attachments; | |
}, 50, 5) |
Set the email you want the attachment to be included in, and add the path to your file. You can find the path from WP Admin → Tools → Site Health → Info → Directories and Sizes → WordPress directory location.
Upload your file to WP Admin → Media, grab the URL and replace the beginning of the URL with the path.