How to add attendee list of specific event to a page?

Home Forums Ticket Products Event Tickets Plus How to add attendee list of specific event to a page?

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1149323
    cecilialai.sze
    Participant

    I 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?

    #1149751
    Nico
    Member

    Hey 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 '

      ';

      foreach ( $attendees as $attendee ) {
      echo '

    • '. $attendee['purchaser_name'] .'(' . $attendee['purchaser_email'] . ')
    • ';
      }

      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,
    Nico

    #1149865
    cecilialai.sze
    Participant

    At 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.

    #1150262
    Nico
    Member

    Thanks 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,
    Nico

    #1150391
    cecilialai.sze
    Participant

    This reply is private.

    #1150393
    cecilialai.sze
    Participant

    4. Is it possible to insert a total number of each ticket type?
    5. Can I have numbering before each attendee?

    #1150673
    Nico
    Member

    Stocked 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 = 0;
      foreach ( $attendees as $attendee ) {
      $i++;
      $output .= '

    • ' . $i . '. ' . $attendee['purchaser_name'] .' (' . $attendee['purchaser_email'] . ') ' . $attendee['provider_slug'] . '<br/>
    • ';
      }

      $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,
    Nico

    #1150849
    cecilialai.sze
    Participant

    This reply is private.

    #1150972
    Nico
    Member

    Hey 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 = 0;
      foreach ( $attendees as $attendee ) {
      $i++;
      $output .= '

    • ' . $i . '. ' . $attendee['purchaser_name'] .' (' . $attendee['purchaser_email'] . ') ' . $attendee['ticket'] . '
    • ';
      }

      $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,
    Nico

    #1151565
    cecilialai.sze
    Participant

    Thank you! It is perfect.

    #1151852
    Nico
    Member

    Woot! 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

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘How to add attendee list of specific event to a page?’ is closed to new replies.