Tribe__Tickets__Tickets::send_tickets_email_for_attendees( array $attendees, array $args = array() )
Send RSVPs/tickets email for attendees.
Contents
Parameters
- $attendees
-
(array) (Required) List of attendees.
- $args
-
(array) (Optional) The list of arguments to use for sending ticket emails.
- 'subject'
(string) The email subject. - 'content'
(string) The email content. - 'from_name'
(string) The name to send tickets from. - 'from_email'
(string) The email to send tickets from. - 'headers'
(array|string) The list of headers to send. - 'attachments'
(array) The list of attachments to send. - 'provider'
(string) The provider slug (rsvp, tpp, woo, edd). - 'post_id'
(int) The post/event ID to send the emails for. - 'order_id'
(string|int) The order ID to send the emails for.
Default value: array()
- 'subject'
Return
(int) The number of emails sent successfully.
Source
File: src/Tribe/Tickets.php
public function send_tickets_email_for_attendees( $attendees, $args = [] ) { $unique_attendees = []; // Collect the unique emails for attendees. foreach ( $attendees as $attendee ) { // If the attendee data is not provided, get it from the provider. if ( ! is_array( $attendee ) ) { $attendee = $this->get_attendee( $attendee ); } // If invalid attendee is set, skip it. if ( ! $attendee ) { continue; } if ( ! isset( $unique_attendees[ $attendee['holder_email'] ] ) ) { $unique_attendees[ $attendee['holder_email'] ] = []; } $unique_attendees[ $attendee['holder_email'] ][] = $attendee; } $emails_sent = 0; // Handle purchaser emails. if ( ! empty( $args['send_purchaser_all'] ) ) { // Get the purchaser email from the first attendee. $first_attendee = reset( $attendees ); $purchaser_email = $first_attendee['purchaser_email']; // Make sure purchaser gets a list of all of the attendee tickets. $unique_attendees[ $purchaser_email ] = $attendees; } // Send an email with all RSVPs/tickets for each unique attendee. foreach ( $unique_attendees as $to => $tickets ) { $emails_sent += (int) $this->send_tickets_email_for_attendee( $to, $tickets, $args ); } return 0 < $emails_sent; }
Changelog
Version | Description |
---|---|
5.0.3 | Introduced. |