Hi James,
This isn’t an altogether ‘neat’ solution as involves duplicating a lot of the code that is used to generate the e-mail for the bookee in order to send the same message (addressed differently) to each ticket holder. But here’s how its done:
You use the eventorganiser_notify_confirmed_booking
filter – this was intended so that the handling of booking confirmation e-mails could be over-ridden. In our case, we’re not going to over-ride it, but insert alongside – in short all ticket holders, the bookee and (if enabled) the site admin receive an e-mail.
Inside our callback for that filter we shall retrieve the tickets for a booking, and for each ticket retrieve the email and name of the ticket holder (I’m assuming you’ve followed this article: http://wp-event-organiser.com/blog/tutorial/attendee-questions/). We’ll then replace the name placeholder tags with the name of the ticket holder, before letting eventorganiser_email_template_tags()
do the rest of the placeholders. Finally we’ll send an e-mail to the ticket holder.
add_filter( 'eventorganiser_notify_confirmed_booking', function( $send_default_email, $booking_id ) {
//Get template
$template = eventorganiser_pro_get_option( 'email_template' );
// Get email details
$from_name = get_bloginfo( 'name' );
$from_email = eo_get_admin_email( $booking_id );
//Set message, subject, headers, attachment and template
$raw_message = eventorganiser_pro_get_option( 'email_tickets_message' );
$subject = apply_filters( 'eventorganiser_booking_confirmed_email_subject', __( 'Thank you for your booking', 'eventorganiserp' ), $booking_id );
$subject = wp_specialchars_decode( $subject, ENT_QUOTES );
$headers = array(
'from:' . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>",
'reply-to:' . $from_email
);
$headers = apply_filters( 'eventorganiser_booking_confirmed_email_headers', $headers, $booking_id );
$attachments = apply_filters( 'eventorganiser_booking_confirmed_email_attachments', array(), $booking_id );
$template = apply_filters( 'eventorganiser_booking_confirmed_email_template', $template, $booking_id );
//Now go through each ticket an e-mail the ticket holder
$tickets = eo_get_booking_tickets( $booking_id, false );
foreach( $tickets as $ticket ) {
// Ticket holder ('attendee') details
$name = eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-name' );
$first_name = $name[0];
$last_name = $name[1];
$email = eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-email', true );
//Replace name tags with name of the ticket holder
$message = str_replace( array( '%first_name%', '%last_name%', '%display_name%' ), array( $first_name, $last_name, "$first_name $last_name" ), $raw_message );
//Replace all other placeholders with appropriate information
$message = eventorganiser_email_template_tags( $message, $booking_id, $template );
$message = apply_filters( 'eventorganiser_booking_confirmed_email_body', wpautop( $message ), $booking_id );
//send!
eventorganiser_mail( $email, $subject, $message, $headers, $attachments, $template );
}
return $send_default_email;
}, 10, 2 );
I hope that helps!