Skip to content

Instantly share code, notes, and snippets.

@vegasgeek
Created February 8, 2014 22:19
Show Gist options
  • Save vegasgeek/8891196 to your computer and use it in GitHub Desktop.
Save vegasgeek/8891196 to your computer and use it in GitHub Desktop.
Attendee export tool for Event Ticketing
<?php
/*
Plugin Name: Event Ticketing - Export Attendees
Description: Display a comma separated list of attendees
Version: 1
Author: 9seeds.com
Author URI: http://9seeds.com/
*/
add_action( 'admin_menu', 'wpet_export_admin' );
function wpet_export_admin() {
add_submenu_page( 'wpet_reports', __( 'Export', 'wptt' ), __( 'Export', 'wptt' ), 'manage_options', 'export-attendees', 'wpet_export_attendees' );
}
function wpet_export_attendees() {
// grab all attendees, display their first/last/email as comma separated values
$args = array(
'post_type' => 'wpet_attendees'
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
$first = str_replace( ',', '', get_post_meta( get_the_ID(), 'wpet_first_name', true ) );
$last = str_replace( ',', '', get_post_meta( get_the_ID(), 'wpet_last_name', true ) );
$email = str_replace( ',', '', get_post_meta( get_the_ID(), 'wpet_email', true ) );
echo $first .','.$last.','.$email.'<br />';
}
} else {
// no posts found
echo 'No Attendees Found';
}
wp_reset_postdata();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment