Created
February 8, 2014 22:19
-
-
Save vegasgeek/8891196 to your computer and use it in GitHub Desktop.
Attendee export tool for Event Ticketing
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 | |
/* | |
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