Created
January 7, 2015 12:04
-
-
Save stephenharris/b17c87bf00590a1c86a7 to your computer and use it in GitHub Desktop.
Displays a simple list of those who've placed a booking for an event
This file contains hidden or 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
| /** | |
| * Appends a list of bookees to the event description. | |
| * If you are selling tickets by 'date', it shows the bookees for each date. | |
| */ | |
| function my_display_attendees( $content ){ | |
| if( 'event' != get_post_type() || !is_singular( 'event' ) ){ | |
| return $content; | |
| } | |
| $occurrences = eo_get_the_occurrences_of( get_the_ID() ); | |
| if( !$occurrences ){ | |
| return $content; | |
| } | |
| $content .= '<h4>Attendees</h4>'; | |
| if( eventorganiser_pro_get_option( 'book_series' ) ){ | |
| //Booking by series, display all bookings | |
| $bookings = eo_get_bookings( array( | |
| 'status' =>'confirmed', | |
| 'event_id' => get_the_ID(), | |
| ) ); | |
| if( !$bookings ){ | |
| continue; | |
| } | |
| $content .= '<ul>'; | |
| foreach( $bookings as $booking ){ | |
| $content .= sprintf( '<li> %1$s</li>', eo_get_booking_meta( $booking->ID, 'bookee_display_name' ) ); | |
| } | |
| $content .= '</ul>'; | |
| }else{ | |
| //Booking by date, display all bookings for each date | |
| foreach( $occurrences as $occurrence_id => $occurrence ){ | |
| $bookings = eo_get_bookings( array( | |
| 'status' =>'confirmed', | |
| 'event_id' => get_the_ID(), | |
| 'occurrence_id' => $occurrence_id, | |
| ) ); | |
| if( !$bookings ){ | |
| continue; | |
| } | |
| if( eo_reoccurs() ){ | |
| $content .= sprintf( '<h5>%s</h5>', $occurrence['start']->format( get_option( 'date_format' ) ) ); | |
| } | |
| $content .= '<ul>'; | |
| foreach( $bookings as $booking ){ | |
| $content .= sprintf( '<li> %1$s</li>', eo_get_booking_meta( $booking->ID, 'bookee_display_name' ) ); | |
| } | |
| $content .= '</ul>'; | |
| } | |
| } | |
| return $content; | |
| } | |
| add_action( 'the_content', 'my_display_attendees' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment