BuddyPress, Events Manager – Custom Attendeelist.php showing attendees

I modified the original code shared by EM on pastebin so that it would show the Buddypress image and membership level as well as the original name.  If you are not using BuddyPress you may wish to the look at the previous link or check out this placeholder replacement.

Within wp-content/themes/CHILD_THEME/plugins/events-manager/placeholders

Create Attendeelist.php

This will override the file included with the original plugin.

/*
 * This custom template will make the username, profile picture and site role show
 * use placeholder #_ATTENDEESLIST in your formatting options at Events > Settings > Formatting > Events
*/
<?php
/* @var $EM_Event EM_Event */
$people = array();
$EM_Bookings = $EM_Event->get_bookings();
if( count($EM_Bookings->bookings) > 0 ){
  ?>
  <div id="attendees">
  <?php
  global $wp_roles;
  if ( !isset( $wp_roles ) )
    $guest_bookings = get_option('dbem_bookings_registration_disable');
  $guest_booking_user = get_option('dbem_bookings_registration_user');
  foreach( $EM_Bookings as $EM_Booking){
    if($EM_Booking->booking_status == 1 && !in_array($EM_Booking->get_person()->ID, $people) ){
      $people[] = $EM_Booking->get_person()->ID;
      echo '<div><span><li><a href="' . bp_core_get_user_domain( $EM_Booking->get_person()->ID ) . '">' . get_avatar($EM_Booking->get_person()->ID, 50) . ' ' . $EM_Booking->get_person()->get_name() .' <font size="-2">(' . $wp_roles->role_names[get_userdata($EM_Booking->get_person()->ID)->roles[0]] . ')</font></a></li></div></span>';
    } elseif ($EM_Booking->booking_status == 1 && $guest_bookings && $EM_Booking->get_person()->ID == $guest_booking_user )
    {
      echo '<li><a href="' . bp_core_get_user_domain( $EM_Booking->get_person()->ID ) . '">' . get_avatar($EM_Booking->get_person()->ID, 50) . ' ' . $EM_Booking->get_person()->get_name() .'</a></li>';
    }
  }
  ?>
  </div>
  <?php
}

There are unnecessary span and divs in the above but it should work.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.