Skip to content

Instantly share code, notes, and snippets.

@Pebblo Pebblo/README.MD
Last active Aug 1, 2019

Embed
What would you like to do?
Example of how to add the 'People' assigned to an event to the registration CSV. #EE #snippet_library
<?php //Please do not add the opening PHP tag if you already have one.
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_in_types = EEH_People_View::get_people_for_event($reg_row['Registration.EVT_ID']);
//Create an array to hold all of the peoples names.
$peoples_names = array();
//Loops though all people types and pull the people assigned to them.
foreach( $people_in_types as $people_type => $people ) {
//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->full_name() . '(' . $people_type . ')';
}
}
}
//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;
}
<?php //Please do not add the opening PHP tag if you already have one.
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);
//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->full_name();
}
}
//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
You can’t perform that action at this time.