Skip to content

Instantly share code, notes, and snippets.

@lorenzocaum
Created September 14, 2020 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorenzocaum/3bd7098e4ec311419fea8d02e85f36a8 to your computer and use it in GitHub Desktop.
Save lorenzocaum/3bd7098e4ec311419fea8d02e85f36a8 to your computer and use it in GitHub Desktop.
add_filter( 'FHEE__EE_Export__report_registrations__reg_csv_array', 'tw_espresso_add_people_to_report_quali_add', 10, 2);
function tw_espresso_add_people_to_report_quali_add( $reg_csv_array, $reg_row ) {
	//Setup the 'People' column even if emtpy.
	$reg_csv_array['qualifikation'] = '';

	//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);

	//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 ) {
			//Add the persons name and type to the peoples_names array
			//This adds them to the CSV using the format - "{person_name}({person_type})"
			$peoples_names[] = $person->get_post_meta( 'qualifikation', true );
		}
	}
	//If we have peoples name, implode the array and add it to the CSV.
	if( !empty($peoples_names) ) {
		$reg_csv_array['qualifikation'] = 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