Last active
July 5, 2019 18:15
-
-
Save joshfeck/a2b9ee9a2d131fcb3b63fa4fccd44da0 to your computer and use it in GitHub Desktop.
add columns for displaying start time and end time in Event Espresso 4 CSV registration report
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 | |
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
add_filter( | |
'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', | |
'ee_add_start_end_time_columns', | |
10, | |
2 | |
); | |
function ee_add_start_end_time_columns( $reg_csv_array, $reg_row ) { | |
$time_format = get_option( 'time_format' ); | |
$ticket_model = \EE_Registry::instance()->load_model('Ticket'); | |
if ($reg_row['Ticket.TKT_ID']) { | |
$datetimes_strings = array(); | |
foreach (\EEM_Datetime::instance()->get_all_wpdb_results( | |
array( | |
array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), | |
'order_by' => array('DTT_EVT_start' => 'ASC'), | |
'default_where_conditions' => 'none', | |
) | |
) as $datetime) { | |
$datetimes_starts[] = \EEH_Export::prepare_value_from_db_for_display( | |
\EEM_Datetime::instance(), | |
'DTT_EVT_start', | |
$datetime['Datetime.DTT_EVT_start'] | |
); | |
$datetimes_ends[] = \EEH_Export::prepare_value_from_db_for_display( | |
\EEM_Datetime::instance(), | |
'DTT_EVT_end', | |
$datetime['Datetime.DTT_EVT_end'] | |
); | |
} | |
} else { | |
return $reg_csv_array; | |
} | |
foreach (array_combine($datetimes_starts, $datetimes_ends) as $datetimes_start => $datetimes_end) { | |
$starts[] = date_i18n( $time_format, strtotime( $datetimes_start ) ); | |
$ends[] = date_i18n( $time_format, strtotime( $datetimes_end ) ); | |
} | |
$reg_csv_array[ "Start Time" ] = implode(", ", $starts); | |
$reg_csv_array[ "End Time" ] = implode(", ", $ends); | |
return $reg_csv_array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment