Help Desk

Maybe I found an issue regarding Tribe__Tickets__Tickets::get_event_attendees( )

  • Posts: 3 Topics: 2
    | Permalink

    Hello folks,

    On behalf of my client Rene, I have a question.

    Why is this working:
    1) $attendees = Tribe__Tickets__Tickets::get_event_attendees( );

    And this is not working:
    2) $attendees = Tribe__Tickets__Tickets::get_event_attendees( $event_id );

    I am afraid this is magic code because it doesn’t make sense. Can you verify it is safe to use line: 1?

    Best regards Thomas Riis

    Posts: 17678 Topics: 17 Answers: 973
    | Permalink

    Hi Thomas,

    That’s an interesting problem!

    Why is this working:
    1) $attendees = Tribe__Tickets__Tickets::get_event_attendees( );

    And this is not working:
    2) $attendees = Tribe__Tickets__Tickets::get_event_attendees( $event_id );

    That’s pretty much exactly the opposite of what I would expect and I don’t experience the same thing: that method requires an event ID to be passed and if you call it without any parameters at all a fatal error will be thrown.

    Could you perhaps share more of your code? Also, when you say that the second approach isn’t working (assuming $event_id is a valid event I’m not sure why it wouldn’t), what are you experiencing exactly?

    Thanks!

    Posts: 3 Topics: 2
    | Permalink

    Hi Barry,

    Yup and it didn’t make sense to me, but when I created more users and they bought tickets. I could see that the call returned all attendees. That could actually be a use case. It was not what I needed so I added the event_id again and it worked.

    Php Storm also complained about the line but no error was thrown. Not even in the error log.

    My method is used for a shortcode:

    public function handle_attendees_shortcode($att){
    
         $output = '';
    
         if (isset($att['id']) 
               && class_exists('Tribe__Tickets__Tickets') 
               && function_exists( 'tribe_tickets_get_attendees' ) ) {
    
            $attendees = Tribe__Tickets__Tickets::get_event_attendees( intval($att['id']) );
    
            $output .= '<div class="row">';
            $output .= '<div class="col-md-3"><h5>Deltagere / købere</h5></div>';
            $output .= '</div>';
            $output .= '<div class="row">';
                    $pid = 0;
                
                    foreach ( $attendees as $attendant ) {
                        //$output .= '<pre>' . print_r( $attendant ) . '</pre>';
                        $output .= '<div class="col-md-3">' . $attendant['purchaser_name'] . '<br>' . 
                        $attendant['purchaser_email'] . '</div>';
                        $eid = $attendant['event_id'];
                     }
    
                $output .= '</div>';
        }
    
        $output .=
        '<div class="riiso-attendees-list">
            <form method="post">
                
                
            </form>
        </div>';
            return $output;
        }

    The shortcode is called from: plugins/the-events-calendar-community-events/src/views/community/event-list.php (and I am using it as a template file – i have added shortcode and send event->ID to the shortcode.

    Hope it makes sense.

    Best regards Thomas

    Posts: 17678 Topics: 17 Answers: 973
    | Permalink

    Hi Thomas! So I see you marked this as resolved — just to be clear, you’re all good here?

    Posts: 3 Topics: 2
    | Permalink

    Yes Barry all good here : )

    • This reply was modified 3 months, 3 weeks ago by  Rene Hansen.
    Posts: 17678 Topics: 17 Answers: 973
    | Permalink

    Excellent – I’ll go ahead and close this topic in that case (but, of course, feel free to open new topics as needed should you require assistance with anything else) 🙂

    | Permalink

The topic ‘Maybe I found an issue regarding Tribe__Tickets__Tickets::get_event_attendees( )’ is closed to new replies.