Last active
October 16, 2023 23:15
-
-
Save andrasguseo/95ed03dfcac67cf49d24e4b6af7d03ad to your computer and use it in GitHub Desktop.
ET+ > Dashboard for all Tickets Commerce attendees
This file contains 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 | |
/** | |
* Show the page in the dashboard for all tickets sold (all attendees) through the Tickets Commerce integration. | |
* It will add an 'All Attendees' submenu under 'Events'. | |
* | |
* Plugins required: Event Tickets | |
* Author: Andras Guseo | |
* Last updated: October 9, 2023 | |
* | |
* @version 5.6.5.1 | |
*/ | |
/** | |
* Modifies the arguments for the 'tec_tc_ticket' post type creation. | |
* Essentially adds a 'Tickets' submenu item under Events, which shows all sold tickets via the Tickets Commerce integration. | |
* | |
* @param array $args The post type arguments. | |
* @param string $post_type The post type. | |
* | |
* @return array The post type arguments. | |
*/ | |
function tec_add_tribe_tcticket_submenu( $args, $post_type ) { | |
// Let's make sure that we're customizing the post type we really need | |
if ( $post_type !== 'tec_tc_attendee' ) { | |
return $args; | |
} | |
$args['show_in_menu'] = 'edit.php?post_type=tribe_events'; | |
$args['show_ui'] = true; | |
$args['label'] = "All Attendees"; | |
return $args; | |
} | |
add_filter( 'register_post_type_args', 'tec_add_tribe_tcticket_submenu', 10, 2 ); | |
/** | |
* Add columns to the post editing screen of the 'tec_tc_ticket' post type. | |
* The columns will be added at the end of the array. | |
* If you want columns to be added in another place, use array_slice(). | |
* | |
* @see manage_{POST TYPE NAME}_posts_columns | |
* | |
* @param array $column_array The array of columns to be displayed. | |
* | |
* @return array The modified array of columns to be displayed. | |
* | |
*/ | |
function tec_et_tc_add_event_column( $column_array ) { | |
$column_array['attendee_email'] = 'Attendee Email'; | |
$column_array['tec_event'] = 'Event Title'; | |
$column_array['et_ticket'] = 'Ticket Name'; | |
return $column_array; | |
} | |
add_filter( 'manage_tec_tc_attendee_posts_columns', 'tec_et_tc_add_event_column' ); | |
/** | |
* Add values to the custom columns on the post editing screen of the 'tec_tc_ticket' post type. | |
* | |
* @param string $column_name The slug of the column name. | |
* @param int $id The ID of the post. | |
* | |
* @return void | |
*/ | |
function tec_et_tc_populate_event_column( $column_name, $id ) { | |
if ( $column_name == 'attendee_email' ) { | |
echo get_post_meta( $id, '_tec_tickets_commerce_email', true ); | |
} | |
if ( $column_name == 'tec_event' ) { | |
$event_id = get_post_meta( $id, '_tec_tickets_commerce_event', true ); | |
$post = get_post( $event_id ); | |
echo $post->post_title; | |
} | |
if ( $column_name == 'et_ticket' ) { | |
$ticket_id = get_post_meta( $id, '_tec_tickets_commerce_ticket', true ); | |
$post = get_post( $ticket_id ); | |
echo $post->post_title; | |
} | |
} | |
add_action( 'manage_tec_tc_attendee_posts_custom_column', 'tec_et_tc_populate_event_column', 999, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment