-
-
Save Pebblo/4afdb79db1db59485047c142d5c22cf8 to your computer and use it in GitHub Desktop.
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 | |
add_filter( 'FHEE__EE_Export__report_registrations__reg_csv_array', 'tw_espresso_add_people_to_report', 10, 2); | |
function tw_espresso_add_people_to_report( $reg_csv_array, $reg_row ) { | |
//Setup the 'People' column even if emtpy. | |
$reg_csv_array['People'] = ''; | |
//Load the people add-on helper. | |
EE_Registry::instance()->load_helper( 'People_View' ); | |
$people = EEM_Person::instance()->get_people_for_event_and_type($reg_row['Registration.EVT_ID'], 3); // 9 is the people type ID | |
//Create an array to hold all of the peoples names. | |
$peoples_names = array(); | |
//Loop through each person assigned to a type. | |
foreach($people as $person ) { | |
//Check we have an EE_Person object. | |
if( $person instanceof EE_Person ) { | |
$qualifications = get_post_meta( $person->ID(), 'qualification', true ); | |
if ( !empty($qualifications) && is_array($qualifications) ) { | |
$qualifications = implode(', ', $qualifications); | |
} | |
//Add the persons name and type to the peoples_names array | |
//This adds them to the CSV using the format - "{person_name} {custom field value}" | |
$peoples_names[] = $person->full_name() . ' ' . $qualifications; // custom field | |
} | |
} | |
//If we have peoples name, implode the array and add it to the CSV. | |
if( !empty($peoples_names) ) { | |
$reg_csv_array['People'] = implode( ', ', $peoples_names); | |
} | |
return $reg_csv_array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment