Tribe__Tickets__Tickets_Handler::maybe_disable_email_resend( bool $allow_resending_email, WP_Post|null $ticket = null, array|null $attendee = null )
Maybe disable the email resend if the attendee has reached their max limit.
Contents
Parameters
- $allow_resending_email
-
(bool) (Required) Whether to allow email resending.
- $ticket
-
(WP_Post|null) (Optional) The ticket post object if available, otherwise null.
Default value: null
- $attendee
-
(array|null) (Optional) The attendee information if available, otherwise null.
Default value: null
Return
(bool) Whether to allow email resending.
Source
File: src/Tribe/Tickets_Handler.php
public function maybe_disable_email_resend( $allow_resending_email, $ticket = null, $attendee = null ) {
// Check if we have an attendee to reference or resending has been disabled already.
if ( ! is_array( $attendee ) || ! $allow_resending_email ) {
return $allow_resending_email;
}
$ticket_sent = (int) Arr::get( $attendee, 'ticket_sent', 0 );
/**
* Allow filtering the maximum number of emails can be resent to an attendee.
*
* Return -1 to remove the limit entirely.
*
* @since 5.1.0
*
* @param int $max_resend_limit The maximum number of emails can be resent to an attendee.
* @param WP_Post|null $ticket The ticket post object if available, otherwise null.
* @param array|null $attendee The attendee information if available, otherwise null.
*/
$max_resend_limit = apply_filters( 'tribe_tickets_handler_email_max_resend_limit', 2, $ticket, $attendee );
// Check if limit is unlimited or if the attendee has been at/sent below the current limit.
if ( -1 === $max_resend_limit || $ticket_sent <= $max_resend_limit ) {
return $allow_resending_email;
}
return false;
}
Changelog
| Version | Description |
|---|---|
| 5.1.0 | Introduced. |