Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of how to add a column that lists the current number of regs vs the total number of spaces currently available on the event
<?php //Please do not include the opening PHP tag if you already have one.
//This code adds a column for 'Pending Payment Registrations'.
function tw_ee_add_pending_payment_registrations_count_column( $columns, $screen ) {
$columns = EEH_Array::insert_into_array(
$columns,
array( 'registrations_pending_payment' => '<span class="dashicons dashicons-groups ee-icon-color-ee-blue ee-icon-size-20"><span class="screen-reader-text">' . esc_html__('Pending Payment Registrations', 'event_espresso') . '</span></span>' ),
'actions'
);
return $columns;
}
add_filter( 'FHEE_manage_toplevel_page_espresso_events_columns', 'tw_ee_add_pending_payment_registrations_count_column', 10, 2 );
function tw_ee_add_pending_payment_registrations_count_column_data( $event, $screen ) {
if ( ! $event instanceof EE_Event ) {
return '';
}
$pending_payment_regs = $event->count_related(
'Registration',
array(
array(
'REG_deleted' => 0,
'STS_ID' => EEM_Registration::status_id_pending_payment,
),
)
);
echo $pending_payment_regs;
}
add_action( 'AHEE__EE_Admin_List_Table__column_registrations_pending_payment__toplevel_page_espresso_events', 'tw_ee_add_pending_payment_registrations_count_column_data', 10, 2 );
<?php //Please do not include the opening PHP tag if you already have one.
//This code adds an additional column 'Regs sold/total'.
function tw_ee_add_registrations_sold_total_column( $columns, $screen ) {
$columns = EEH_Array::insert_into_array(
$columns,
array( 'registrations_sold_total' => 'Regs sold/total' ),
'actions'
);
return $columns;
}
add_filter( 'FHEE_manage_toplevel_page_espresso_events_columns', 'tw_ee_add_registrations_sold_total_column', 10, 2 );
function tw_ee_add_registrations_sold_total_column_data( $event, $screen ) {
if ( ! $event instanceof EE_Event ) {
return '';
}
$registered_attendees = EEM_Registration::instance()->get_event_registration_count($event->ID());
$total_spaces = $event->total_available_spaces() == EE_INF ? '&infin;' : $event->total_available_spaces();
echo $registered_attendees . '/' . $total_spaces;
}
add_action( 'AHEE__EE_Admin_List_Table__column_registrations_sold_total__toplevel_page_espresso_events', 'tw_ee_add_registrations_sold_total_column_data', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.