Home › Forums › Ticket Products › Event Tickets Plus › How to add attendee list of specific event to a page?
- This topic has 11 replies, 3 voices, and was last updated 9 years, 8 months ago by
cecilialai.sze.
-
AuthorPosts
-
August 9, 2016 at 12:13 am #1149323
cecilialai.sze
ParticipantI want to show specific attendee list on a single page, but not under the event page. Because I want to set a password to that page, which only allow users with password to get into it. Do there any custom code or link which can achieve?
-
This topic was modified 9 years, 9 months ago by
cecilialai.sze.
August 9, 2016 at 3:43 pm #1149751Nico
MemberHey Cecilia,
Thanks for reaching out to us! I can help you here π
I crafted a simple shortcode to get you started on this customization. Just paste the code below in your theme’s (or child theme’s) functions.php file:
/* Shortcode to display attendees list for a given event id [tribe_get_event_attendees event_id=11] */
function tribe_get_event_attendees_logic ( $atts ) {if ( !class_exists( 'Tribe__Tickets__Tickets' ) || !isset($atts['event_id']) ) return false;
$event_id = $atts['event_id'];
$attendees = Tribe__Tickets__Tickets::get_event_attendees( $event_id );
if( !empty($attendees) ) {
echo '
Attendees List: ' . get_the_title( $event_id ) . '
';
echo '- ';
- '. $attendee['purchaser_name'] .'(' . $attendee['purchaser_email'] . ')
foreach ( $attendees as $attendee ) {
echo '';
}echo '
';
} else {
echo 'There are still no attendees for this event
';
}
}
add_shortcode( 'tribe_get_event_attendees', 'tribe_get_event_attendees_logic' );
Once the code is in place you’ll be able to use the shortcode like this: [tribe_get_event_attendees event_id=11].
Please give this a try and let me know if it works for you,
Best,
NicoAugust 9, 2016 at 11:32 pm #1149865cecilialai.sze
ParticipantAt this stage, I got ‘<p>There are still no attendees for this event</p> ‘ this in the page, but there is attendee in my list on the admin page. Is it correct that event_id is the second item under quick edit of the event? I don’t know whether I input the correct event_id.
August 10, 2016 at 3:11 pm #1150262Nico
MemberThanks for following up Cecilia!
You can see the event ID in the URL when you are editing the event β https://cloudup.com/cG5NvfLycIB
Please give this a new try and let me know if it works now,
Best,
NicoAugust 11, 2016 at 12:31 am #1150391cecilialai.sze
ParticipantThis reply is private.
-
This reply was modified 9 years, 8 months ago by
cecilialai.sze.
August 11, 2016 at 12:42 am #1150393cecilialai.sze
Participant4. Is it possible to insert a total number of each ticket type?
5. Can I have numbering before each attendee?August 11, 2016 at 11:43 am #1150673Nico
MemberStocked to hear this is working now!
/* Shortcode to display attendees list for a given event id [tribe_get_event_attendees event_id=11] */
function tribe_get_event_attendees_logic ( $atts ) {if ( ! class_exists( 'Tribe__Tickets__Tickets' ) || ! isset( $atts['event_id'] ) ) {
return false;
}$event_id = intval( $atts['event_id'] );
if ( empty( $event_id ) ) {
return false;
}$attendees = Tribe__Tickets__Tickets::get_event_attendees( $event_id );
$output = '';
if( ! empty( $attendees ) ) {
$output .= '
Attendees List: ' . get_the_title( $event_id ) . ' - ' . count($attendees) .'
';
$output .= '- ';
- ' . $i . '. ' . $attendee['purchaser_name'] .' (' . $attendee['purchaser_email'] . ') ' . $attendee['provider_slug'] . '<br/>
$i = 0;
foreach ( $attendees as $attendee ) {
$i++;
$output .= '';
}$output .= '
';
} else {
$output .= '<p>There are no attendees for this event yet.</p>';
}return $output;
}
add_shortcode( 'tribe_get_event_attendees', 'tribe_get_event_attendees_logic' );
I updated the code to include a line break in each li, also added the order numbers and the total attendees count as well as the ticket provider. While it’s possible to make the counts for each provider that’s a bit out of the support scope we can provide here!
Please let me know if this works,
Best,
NicoAugust 12, 2016 at 12:25 am #1150849cecilialai.sze
ParticipantThis reply is private.
August 12, 2016 at 9:10 am #1150972Nico
MemberHey glad to hear it works π
Sorry for the confusion, here’s the updated code:
/* Shortcode to display attendees list for a given event id [tribe_get_event_attendees event_id=11] */
function tribe_get_event_attendees_logic ( $atts ) {if ( ! class_exists( 'Tribe__Tickets__Tickets' ) || ! isset( $atts['event_id'] ) ) {
return false;
}$event_id = intval( $atts['event_id'] );
if ( empty( $event_id ) ) {
return false;
}$attendees = Tribe__Tickets__Tickets::get_event_attendees( $event_id );
$output = '';
if( ! empty( $attendees ) ) {
$output .= '
Attendees List: ' . get_the_title( $event_id ) . ' - ' . count($attendees) .'
';
$output .= '- ';
- ' . $i . '. ' . $attendee['purchaser_name'] .' (' . $attendee['purchaser_email'] . ') ' . $attendee['ticket'] . '
$i = 0;
foreach ( $attendees as $attendee ) {
$i++;
$output .= '';
}$output .= '
';
} else {
$output .= 'There are no attendees for this event yet.
';
}return $output;
}
add_shortcode( 'tribe_get_event_attendees', 'tribe_get_event_attendees_logic' );
Please let me know about it,
Best,
NicoAugust 15, 2016 at 12:57 am #1151565cecilialai.sze
ParticipantThank you! It is perfect.
August 15, 2016 at 4:09 pm #1151852Nico
MemberWoot! Glad to hear this helps you out Cecilia π
Iβll go ahead and close out this thread, but if you need help with anything else please donβt hesitate to create a new one and we will be happy to assist you.
Best,
Nico -
This topic was modified 9 years, 9 months ago by
-
AuthorPosts
- The topic ‘How to add attendee list of specific event to a page?’ is closed to new replies.
