Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Created August 21, 2025 10:14
Show Gist options
  • Save andrasguseo/c878a9404aa32dfc1a7720cebf66d6f3 to your computer and use it in GitHub Desktop.
Save andrasguseo/c878a9404aa32dfc1a7720cebf66d6f3 to your computer and use it in GitHub Desktop.
ET > Add security code column on the Attendees page and the Attendees export
<?php
/**
* Add security code column on the Attendees page and the Attendees export.
* Usage: Add the snippet with Code Snippets or to your functions.php file.
*
* @author: Andras Guseo
*
* Plugins required: Event Tickets
*
* @since August 21, 2025 Initial version.
*/
// Adding an extra column header for Security Code.
add_filter( 'tribe_tickets_attendee_table_columns', function ( $columns ) {
/**
* Choose below after which column you would like to add the purchase time
* 'cb', 'ticket', 'primary_info', 'status', 'check_in'
*/
$insert_after_column = 'primary_info';
foreach ( $columns as $key => $value ) {
$new_columns[$key] = $value;
if ( $key == $insert_after_column ) {
$new_columns['security'] = "Security code";
}
}
return $new_columns;
} );
// Adding the values to the security code column.
add_filter( 'tribe_events_tickets_attendees_table_column', function ( $value, $item, $column ) {
if ( $column == 'security' ) {
$value = $item['security_code'];
}
return $value;
}, 10, 3 );
/**
* Export functions
*/
add_action( 'tribe_events_tickets_generate_filtered_attendees_list', function ( $event_id ) {
if ( ! is_admin() ) {
$screen_base = 'tribe_events_page_tickets-attendees';
} else {
$screen = get_current_screen();
$screen_base = $screen->base;
}
$filter_name = "manage_{$screen_base}_columns";
add_filter( $filter_name, 'tribe_export_custom_add_columns', 100 );
add_filter( 'tribe_events_tickets_attendees_table_column', 'tribe_export_custom_populate_columns', 10, 3 );
} );
function tribe_export_custom_add_columns ( $columns ) {
$columns['security'] = "Security code";
return $columns;
}
function tribe_export_custom_populate_columns ( $value, $item, $column ) {
if ( isset( $item['user_id'] ) && (int) $item['user_id'] > 0 ) {
if ( 'security' === $column ) {
$value = $item['security_code'];
}
} else {
$value = '-';
}
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment