Skip to content

Instantly share code, notes, and snippets.

@altuno
Created February 28, 2017 21:14
Show Gist options
  • Save altuno/bd583ae4f70354d0961adfa9be8f33ee to your computer and use it in GitHub Desktop.
Save altuno/bd583ae4f70354d0961adfa9be8f33ee to your computer and use it in GitHub Desktop.
//* Add instructor name to EE4 CSV Download
add_filter( 'FHEE__EE_Export__report_registrations__reg_csv_array', 'espresso_add_author_to_report', 10, 2);
function espresso_add_author_to_report( $reg_csv_array, $reg_row ) {
$event_id = $reg_row['Registration.EVT_ID'];
$event = EEM_Event::instance()->get_one_by_ID( $event_id );
if ( $event instanceof EE_Event ) {
$post_author = get_post_field( 'post_author', $event_id );
$author_info = get_userdata( $post_author );
$reg_csv_array['Author'] = $author_info->last_name . ", " . $author_info->first_name;
}
return $reg_csv_array;
}
// Add event categories to EE4 csv download
function ee_tw_event_categories_to_csv( $reg_csv_array, $reg_row ) {
$EVT_ID = $reg_row[ 'Event_CPT.ID'];
$terms = array();
$event_categories = get_the_terms( $EVT_ID, 'espresso_event_categories' );
if ( $event_categories ) {
foreach( $event_categories as $term ) {
$terms[] = $term->name;
}
$terms = implode( ' ', $terms);
}
$reg_csv_array['Event Categories'] = !empty($terms) ? $terms : '';
return $reg_csv_array;
}
add_filter( 'FHEE__EE_Export__report_registrations__reg_csv_array', 'ee_tw_event_categories_to_csv', 10, 2 );
//* Add language tags to the CSV Download
add_filter( 'FHEE__EE_Export__report_registrations__reg_csv_array', 'espresso_add_tag_to_report', 10, 2);
function espresso_add_tag_to_report( $reg_csv_array, $reg_row ) {
$event_id = $reg_row['Registration.EVT_ID'];
$event = EEM_Event::instance()->get_one_by_ID( $event_id );
if ( $event instanceof EE_Event ) {
$posttags = get_the_tags( $event_id );
if ($posttags) {
foreach($posttags as $tag) {
$reg_csv_array['Tag'] = $tag->name;
}
}
}
return $reg_csv_array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment