<?php
/**
* Event Tickets & Plus: Attach a file from Media Library to all ticket emails.
*
* Does not work for emails for declined RSVPs or for moved tickets, but it
* could if you want it to; just add those additional hooks.
*
* @link https://gist.github.com/cliffordp/fc7f1687b26c7292672ead9f26c4d568
* @link https://theeventscalendar.com/support/forums/topic/pdf-attachment-file-to-ticket-email/
*/
function cliff_attach_file_to_all_tickets( array $attachments ) {
// !!! CHANGE THIS !!!
$attachment_id = 6391;
// We do it this way to make sure we get the path, not the link.
$file = get_attached_file( $attachment_id );
if ( file_exists( $file ) ) {
$attachments[] = $file;
}
return $attachments;
}
add_action( 'tribe_rsvp_email_attachments', 'cliff_attach_file_to_all_tickets', 50 );
add_action( 'tribe_tpp_email_attachments', 'cliff_attach_file_to_all_tickets', 50 );
add_action( 'tribe_tickets_plus_woo_email_attachments', 'cliff_attach_file_to_all_tickets', 50 );
add_action( 'edd_ticket_receipt_attachments', 'cliff_attach_file_to_all_tickets', 50 );