Recently i have come across a requirement to generate a csv report which contains all the event Attendee details in it.
$testing = tribe_get_events ();
$AllEventAttendeesExport= Array();
$titleFields = array();
foreach ($testing as $keysas => $valueas) {
$fields = array();
$fields = Tribe__Tickets_Plus__Main::instance()->meta()->get_meta_fields_by_event( $valueas->ID );
$AllEventAttendeesExport[$valueas->ID]['titles'][] = 'Event Ticket';
$AllEventAttendeesExport[$valueas->ID]['titles'][] = 'Primary-Information';
$AllEventAttendeesExport[$valueas->ID]['titles'][] = 'Security Code';
$AllEventAttendeesExport[$valueas->ID]['titles'][] = 'Check in';
foreach ($fields as $keyfields => $valuefields) {
$AllEventAttendeesExport[$valueas->ID]['titles'][] = $valuefields->label;
}
$items = Tribe__Tickets__Tickets::get_event_attendees( $valueas->ID );
foreach ($items as $keyI => $valueI) {
$meta_data = get_post_meta( $valueI['attendee_id'], Tribe__Tickets_Plus__Meta::META_KEY, true );
$AllEventAttendeesExport[$valueas->ID]['Values'][$keyI][] = $valueas->post_title;
$AllEventAttendeesExport[$valueas->ID]['Values'][$keyI][] = '';
$AllEventAttendeesExport[$valueas->ID]['Values'][$keyI][] = $valueI['security'];
$AllEventAttendeesExport[$valueas->ID]['Values'][$keyI][] = $valueI['check_in'];
foreach ($meta_data as $keyMta => $valueMta) {
$AllEventAttendeesExport[$valueas->ID]['Values'][$keyI][] = $valueMta;
}
}
}
All the events with event title and ticket details will be there in the below Array.
print_r($AllEventAttendeesExport);
Use some CSV library to export this final result.
$testing = tribe_get_events ();
$AllEventAttendeesExport= Array();
$titleFields = array();
foreach ($testing as $keysas => $valueas) {
$fields = array();
$fields = Tribe__Tickets_Plus__Main::instance()->meta()->get_meta_fields_by_event( $valueas->ID );
$AllEventAttendeesExport[$valueas->ID]['titles'][] = 'Event Ticket';
$AllEventAttendeesExport[$valueas->ID]['titles'][] = 'Primary-Information';
$AllEventAttendeesExport[$valueas->ID]['titles'][] = 'Security Code';
$AllEventAttendeesExport[$valueas->ID]['titles'][] = 'Check in';
foreach ($fields as $keyfields => $valuefields) {
$AllEventAttendeesExport[$valueas->ID]['titles'][] = $valuefields->label;
}
$items = Tribe__Tickets__Tickets::get_event_attendees( $valueas->ID );
foreach ($items as $keyI => $valueI) {
$meta_data = get_post_meta( $valueI['attendee_id'], Tribe__Tickets_Plus__Meta::META_KEY, true );
$AllEventAttendeesExport[$valueas->ID]['Values'][$keyI][] = $valueas->post_title;
$AllEventAttendeesExport[$valueas->ID]['Values'][$keyI][] = '';
$AllEventAttendeesExport[$valueas->ID]['Values'][$keyI][] = $valueI['security'];
$AllEventAttendeesExport[$valueas->ID]['Values'][$keyI][] = $valueI['check_in'];
foreach ($meta_data as $keyMta => $valueMta) {
$AllEventAttendeesExport[$valueas->ID]['Values'][$keyI][] = $valueMta;
}
}
}
All the events with event title and ticket details will be there in the below Array.
print_r($AllEventAttendeesExport);
Use some CSV library to export this final result.