Last active
April 10, 2022 17:06
-
-
Save cliffordp/fc7f1687b26c7292672ead9f26c4d568 to your computer and use it in GitHub Desktop.
Event Tickets & Plus: Attach a file from Media Library to all ticket emails.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
I'm also looking for a solution to attach event-specific document !
@mariomelchor & @fabricelaborie - I'm sure you could create a custom field to pick a media item (or just get the featured image, for example) for each event (or use Events Calendar Pro's custom fields) and incorporate that into this snippet somehow
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is great for adding attachments to all ticket emails. Is it possible to add attachments for a specific event only?