Tribe__Tickets__Admin__Move_Tickets::notify_attendees( array $ticket_ids, int $tgt_ticket_type_id, int $src_event_id, int $tgt_event_id )
Notifies the ticket owners that their tickets have been moved to a new ticket type.
Contents
Parameters
- $ticket_ids
-
(array) (Required)
- $tgt_ticket_type_id
-
(int) (Required)
- $src_event_id
-
(int) (Required)
- $tgt_event_id
-
(int) (Required)
Source
File: src/Tribe/Admin/Move_Tickets.php
public function notify_attendees( $ticket_ids, $tgt_ticket_type_id, $src_event_id, $tgt_event_id ) {
$to_notify = array();
$args = [
'in' => $ticket_ids,
'by' => [
'ticket' => $tgt_ticket_type_id,
],
];
$attendee_data = Tribe__Tickets__Tickets::get_event_attendees_by_args( $tgt_event_id, $args );
// Build a list of email addresses we want to send notifications of the change to
foreach ( $attendee_data['attendees'] as $attendee ) {
// Skip if an email address isn't available
if ( ! isset( $attendee['purchaser_email'] ) ) {
continue;
}
if ( ! isset( $to_notify[ $attendee['purchaser_email'] ] ) ) {
$to_notify[ $attendee['purchaser_email'] ] = array( $attendee );
} else {
$to_notify[ $attendee['purchaser_email'] ][] = $attendee;
}
}
foreach ( $to_notify as $email_addr => $affected_tickets ) {
/**
* Sets the moved ticket email address.
*
* @param string $email_addr
*/
$to = apply_filters( 'tribe_tickets_ticket_moved_email_recipient', $email_addr );
/**
* Sets any attachments for the moved ticket email address.
*
* @param array $attachments
*/
$attachments = apply_filters( 'tribe_tickets_ticket_moved_email_attachments', array() );
/**
* Sets the HTML for the moved ticket email.
*
* @param string $html
*/
$content = apply_filters( 'tribe_tickets_ticket_moved_email_content',
$this->generate_email_content( $tgt_ticket_type_id, $src_event_id, $tgt_event_id, $affected_tickets )
);
/**
* Sets any headers for the moved tickets email.
*
* @param array $headers
*/
$headers = apply_filters( 'tribe_tickets_ticket_moved_email_headers',
array( 'Content-type: text/html' )
);
/**
* Sets the subject line for the moved tickets email.
*
* @param string $subject
*/
$subject = apply_filters( 'tribe_tickets_ticket_moved_email_subject',
sprintf( __( 'Changes to your tickets from %s', 'event-tickets' ), get_bloginfo( 'name' ) )
);
wp_mail( $to, $subject, $content, $headers, $attachments );
}
}