SHARE
TWEET

Custom #_ATTENDEES placeholder inc. booking space attendees

eventsmanager May 8th, 2017 (edited) 365 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3.  * This snippet will override template when using placeholder #_ATTENDEES and will add attendee names captured by attendee form
  4.  * This assumes that you are using a field with ID attendee_name in your attendee form.
  5.  *
  6.  * How to install:
  7.  * 1. create these folders within your theme directory
  8.  *    wp-contents > themes > Your Theme > (create these folders) plugins > events-manager > placeholders
  9.  * 2. create attendees.php inside placeholder folder at step#1 then edit
  10.  * 3. paste this whole snippet
  11.  */
  12. /* @var $EM_Event EM_Event */
  13. $people = array();
  14. $EM_Bookings = $EM_Event->get_bookings();
  15. if( count($EM_Bookings->bookings) > 0 ){
  16.     ?>
  17.     <ul class="event-attendees">
  18.     <?php
  19.     foreach( $EM_Bookings as $EM_Booking){ /* @var $EM_Booking EM_Booking */
  20.        
  21.         $attendees = $EM_Booking->booking_meta['attendees'];
  22.        
  23.         if($EM_Booking->booking_status == 1 && !in_array($EM_Booking->get_person()->ID, $people) ){
  24.             $people[] = $EM_Booking->get_person()->ID;
  25.             echo '<li>'. $EM_Booking->get_person()->get_name() .' '. get_avatar($EM_Booking->get_person()->ID, 50) .'</li>';       
  26.         }elseif($EM_Booking->booking_status == 1 && $EM_Booking->is_no_user() ){
  27.             echo '<li>'. $EM_Booking->get_person()->get_name() .' '. get_avatar($EM_Booking->get_person()->ID, 50) .'</li>';
  28.         }
  29.         $attendees_list = "<ul>";
  30.         if ( !empty($attendees) ){
  31.             $count = 0;
  32.             foreach($attendees as $key => $value) {
  33.                 foreach($value as $key_attendee => $value_attendee) {
  34.                     if ( $count >= 1 )$attendees_list .= "<li>".$value_attendee["attendee_name"]."</li>";
  35.                     $count += 1;
  36.                 }
  37.             }
  38.         }
  39.         echo $attendees_list."</ul>";
  40.     }
  41.     ?>
  42.     </ul>
  43.     <?php
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top