Skip to content

Instantly share code, notes, and snippets.

@jentheo
Last active May 24, 2017 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jentheo/7772fd5a1e665379468243bc0b3a130e to your computer and use it in GitHub Desktop.
Save jentheo/7772fd5a1e665379468243bc0b3a130e to your computer and use it in GitHub Desktop.
Remove checked in tickets from Attendees list (RSVP & WooCommerce)
<?php
function attendee_screen_filter_out_checked_in_attendees( $query ) {
$attendee_post_types = array(
'tribe_rsvp_attendees',
'tribe_wooticket'
);
if ( ! in_array( $query->get( 'post_type' ), $attendee_post_types ) ) {
return;
}
// Reform meta query - filter out those already checked in
$meta_query = array(
array(
'key' => $query->get( 'meta_key' ),
'value' => $query->get( 'meta_value' )
),
array(
'key' => '_tribe_rsvp_checkedin',
'compare' => 'NOT EXISTS'
),
array(
'key' => '_tribe_wooticket_checkedin',
'compare' => 'NOT EXISTS'
)
);
// Clear out previous meta query
$query->set( 'meta_key', '' );
$query->set( 'meta_value', '' );
// Update
$query->set( 'meta_query', $meta_query );
}
function attendee_screen_remove_checked_in_attendees_setup() {
add_action( 'pre_get_posts', 'attendee_screen_filter_out_checked_in_attendees', 200 );
}
function attendee_screen_remove_checked_in_attendees_teardown( $passthru ) {
remove_action( 'pre_get_posts', 'attendee_screen_filter_out_checked_in_attendees', 200 );
return $passthru;
}
add_action( 'tribe_tickets_attendees_page_inside', 'attendee_screen_remove_checked_in_attendees_setup' );
add_filter( 'tribe_tickets_event_attendees', 'attendee_screen_remove_checked_in_attendees_teardown' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment