Created
June 3, 2020 18:47
-
-
Save rafsuntaskin/af000dfa0907a63feb19fcdb56334990 to your computer and use it in GitHub Desktop.
Reset deleted count for RSVP tickets when all attendees and tickets are removed
This file contains hidden or 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 | |
/** | |
* Custom reset for attendee deletion count if all attendees are deleted | |
*/ | |
add_action( 'tickets_rsvp_ticket_deleted', 'rt_reset_deleted_data_if_attendee_not_available', 20, 3 ); | |
function rt_reset_deleted_data_if_attendee_not_available( $ticket_id, $event_id, $product_id ) { | |
$total_attendees = Tribe__Tickets__Tickets::get_event_attendees_count( $event_id ); | |
if ( $total_attendees != 0 ) { | |
return; | |
} | |
update_post_meta( $event_id, '_tribe_deleted_attendees_count', 0 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment