Skip to content

Instantly share code, notes, and snippets.

@rafsuntaskin
Created June 3, 2020 18:47
Show Gist options
  • Save rafsuntaskin/af000dfa0907a63feb19fcdb56334990 to your computer and use it in GitHub Desktop.
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
<?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