Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Created January 20, 2021 21:30
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 andrasguseo/b6a0090c3d26ebbadddedde97b8929a1 to your computer and use it in GitHub Desktop.
Save andrasguseo/b6a0090c3d26ebbadddedde97b8929a1 to your computer and use it in GitHub Desktop.
ET: Add purchase time on the Attendees admin page in Event Tickets
<?php
/* Description: Add purchase time on the Attendees admin page in Event Tickets
* Usage: Paste the below snippet into your active (child) theme's functions.php file
*
* Plugin: Event Tickets
* Author: Andras Guseo
* Last updated: 2021-01-20
*/
// Adding an extra column header for Purchase time
add_filter( 'tribe_tickets_attendee_table_columns', 'tec_et_purchase_time_column' );
function tec_et_purchase_time_column( $columns ) {
/**
* Choose below after which column you would like to add the purchase time
* 'cb', 'ticket', 'primary_info', 'security', 'status', 'check_in'
*/
$insert_after_column = 'primary_info';
foreach ( $columns as $key => $value ) {
$new_columns[$key] = $value;
if ( $key == $insert_after_column ) {
$new_columns['purchase_time'] = "Purchase time";
}
}
return $new_columns;
}
// Adding the values to the purchase time column
add_filter( 'tribe_events_tickets_attendees_table_column', 'tec_et_purchase_time_column_data', 10, 3 );
function tec_et_purchase_time_column_data( $value, $item, $column ) {
if ( $column == 'purchase_time' ) {
$ptime = strtotime( $item['purchase_time'] );
$ptime = date( get_option( 'date_format' ), $ptime ) .
' at ' .
date( get_option( 'time_format' ), $ptime );
$value = $ptime;
}
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment