eventsmanager

#_ATTENDEESLIST template with Attendee Form

Jun 15th, 2020
126
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /*
  4. * This snippet will override template when using placeholder #_ATTENDEESLIST and will add attendee names captured by attendee form
  5. * This assumes that you are using a field with ID attendee_name in your attendee form.
  6. *
  7. * How to install:
  8. * 1. create these folders within your theme directory
  9. * wp-contents > themes > Your Theme > (create these folders) plugins > events-manager > placeholders
  10. * 2. create attendeeslist.php inside placeholder folder at step#1 then edit
  11. * 3. paste this whole snippet
  12. */
  13.  
  14. /* @var $EM_Event EM_Event */
  15. $people = array();
  16. $EM_Bookings = $EM_Event->get_bookings();
  17. if( count($EM_Bookings->bookings) > 0 ){
  18. ?>
  19. <ul class="event-attendees">
  20. <?php
  21. foreach( $EM_Bookings as $EM_Booking){ /* @var $EM_Booking EM_Booking */
  22. if($EM_Booking->booking_status == 1 && !in_array($EM_Booking->get_person()->ID, $people) ){
  23. $people[] = $EM_Booking->get_person()->ID;
  24.  
  25. echo '<li>';
  26. echo $EM_Booking->get_person()->get_name() . ' - ' . $EM_Booking->get_spaces() . ' space(s)';
  27. echo '<ul>';
  28. $EM_Tickets_Bookings = $EM_Booking->get_tickets_bookings();
  29. $attendee_datas = EM_Attendees_Form::get_booking_attendees($EM_Booking);
  30. foreach( $EM_Tickets_Bookings->tickets_bookings as $EM_Ticket_Booking ){
  31. if( !empty($attendee_datas[$EM_Ticket_Booking->ticket_id]) ){
  32. foreach( $attendee_datas[$EM_Ticket_Booking->ticket_id] as $attendee_title => $attendee_data ){
  33. echo '<li>';
  34. echo $attendee_data['attendee_name'].' - '.$attendee_data['attendee_email']; //Forms Editor > Attendee Form > Field Id
  35. echo '</li>';
  36. }
  37. }
  38. }
  39. echo '</ul>';
  40. echo '</li>';
  41.  
  42. }elseif($EM_Booking->booking_status == 1 && $EM_Booking->is_no_user() ){
  43.  
  44. echo '<li>';
  45. echo $EM_Booking->get_person()->get_name() . ' - ' . $EM_Booking->get_spaces() . ' space(s)';
  46. echo '<ul>';
  47. $EM_Tickets_Bookings = $EM_Booking->get_tickets_bookings();
  48. $attendee_datas = EM_Attendees_Form::get_booking_attendees($EM_Booking);
  49. foreach( $EM_Tickets_Bookings->tickets_bookings as $EM_Ticket_Booking ){
  50. if( !empty($attendee_datas[$EM_Ticket_Booking->ticket_id]) ){
  51. foreach( $attendee_datas[$EM_Ticket_Booking->ticket_id] as $attendee_title => $attendee_data ){
  52. echo '<li>';
  53. echo $attendee_data['attendee_name'].' - '.$attendee_data['attendee_email']; //Forms Editor > Attendee Form > Field Id
  54. echo '</li>';
  55. }
  56. }
  57. }
  58. echo '</ul>';
  59. echo '</li>';
  60.  
  61.  
  62. }
  63. }
  64. ?>
  65. </ul>
  66. <?php
  67. }
RAW Paste Data