[Plugin: Events Manager] Display attendees in a page
-
Greetings,
I have read the instructions for eventmangers but I don’t know how to display a page containing a list of attendees for an event. I have only one event on my site.
You have to book to attend to the event so as I understand the RSVP condition is fullfilled. I’ve tried to put #ATTENDEES in a page but it does not work.Any suggestions? ??
Regards
ZyberFart.
-
I too need the exact same scenario. I have it working fine, except that the get_spaces() seem to return the last booking’s number of spaces.
Here is my code:
<?php /* @var $EM_Event EM_Event */ $people = array(); foreach($EM_Event->get_bookings() as $EM_Booking){ $people[$EM_Booking->person->ID] = $EM_Booking->person; } ?> <BR>The following members are attending this event: <BR><BR> <?php foreach($people as $EM_Person): ?> <p> <?php echo $EM_Person->user_firstname . " " . $EM_Person->user_lastname . " + " . $EM_Booking->get_spaces(); if ($EM_Booking->get_spaces() > 1) echo " Additional People"; else echo " Additional Person"; ?> <?php endforeach; ?>
The reason its not working is because $EM_Booking is not part of the loop, but I don’t know how to fix it. It seems to me that if there was a $EM_Person->spaces that it would work.
that’s because your first foreach loop is setting $EM_Booking and reused in the second one.
@arizonai – did you ever make any more progress on your code?
@all, was there a final recommended way to use this. I just set up a small site for my friends where we are doing dinners and events with folks doing an rsvp and it would be great to show who has already done an rsvp. It would save me from getting phone calls “is so and so going”.
I’d love to show it on the single event page. I tried the #_ATTENDEES but only got one icon even though three people had already done an rsvp.
Perhaps it’s a 5 version item?
Try my implementation. I did not read up all the comments to the lasthere, but this information table was satisfying our needs so far (there are no action links for each attendee entry here)
You get a list of peopel attending with the time they committed and a comment as well. At last, you get a summary of how many participate. YOUR entry is highlited if found.<?php /* * Called by wp-content/themes/twentyten/plugins/events-manager/placeholders/attendees.php * Called by procedure described in /wp-content/plugins/events-manager/templates/placeholders/readme.txt * * * @Shonu * @Date 16/08/2011 11:45:19 */ showBookingsTable(); ########################################################################################################## function showBookingsTable($attributes = array()){ global $EM_Event; if(!$EM_Event || !$EM_Event->rsvp ) return; $lister = $EM_Event->get_bookings(); ///$bookings->get( $args = array());// $bookerList = $lister->bookings; $wpCurrentUserObj = wp_get_current_user(); $currentUserID = $wpCurrentUserObj->ID; $userProfile = "/wp-admin/user-edit.php?user_id=#ID#"; $table .= "<tr>" ."<th>Full Name</th>" ."<th>Time registered</th>" ."<th>Status</th>" ."<th>Seats</th>" ."<th>Comments</th>" ."</tr>"; //error_reporting(E_WARNING); foreach($bookerList as $EM_Booking) { $atendeesNo = $atendeesNo + $EM_Booking->spaces; if(0){ echo "<pre>"; print_r($EM_Booking); echo "</pre>"; } $bookedUserID = $EM_Booking->person_id;//Not the user ID!! It is a ticket id or so $personObj = $EM_Booking->person; $userFirstname = $personObj->first_name; $userLastname = $personObj->last_name; $userDispname = $EM_Booking->person->display_name; if(0){ echo "<pre>"; print_r($personObj); echo "</pre>"; } /* @var $EM_Booking EM_Booking */ $aTRs = array(); foreach( $EM_Booking->get_tickets_bookings() as $EM_Ticket_Booking) { /* @var $EM_Ticket EM_Ticket */ /* @var $EM_Ticket_Booking EM_Ticket_Booking */ $EM_Ticket = $EM_Ticket_Booking->get_ticket(); $isCurrentUser = $bookedUserID == $currentUserID; $userName = "<span title='login or register to reveal'>*********</span>"; if(is_user_logged_in()){ if($userLastname && $userFirstname) $userName = $userFirstname . " " . $userLastname ; else //if($userFirstname) //$userName = $EM_Booking->person->display_name; $userName = $userDispname; } $sorterStringPrefix = "<!-- ".$EM_Booking->timestamp."-->"; //$userProfile = $currentUserID ? "<a href=\"".str_replace("#ID#", $currentUserID, $userProfile)."\">$userName</a>":$userName; $row = array( //$EM_Booking->id, $userName ,//. " [$bookedUserID = $currentUserID]" //$EM_Booking->person->user_email, //$EM_Booking->person->phone, date('d.m.Y H:i', $EM_Booking->timestamp), $EM_Booking->get_status(), //$EM_Ticket->name, $EM_Ticket_Booking->get_spaces(), //$EM_Ticket_Booking->get_price(), preg_replace("/<|>/", "-", $EM_Booking->comment) ); //Display all values $newTR = $sorterStringPrefix."<tr ".($isCurrentUser ? "style='background-color:#FFFFDD;'":"")."><!-- $currentUserID === {$EM_Booking->id} -->\r\n"; foreach($row as $value){ //$value = str_replace('"', '""', $value); //$value = str_replace("=", "", $value); //$file .= '"' . preg_replace("/\n\r|\r\n|\n|\r/", ". ", $value) . '",'; $newTR .= "\t<td>" . $value . "</td>\r\n"; } $newTR .= "</tr>\r\n"; $aTRs[$EM_Booking->timestamp] = $newTR; } if(0) $table .= $newTR; else{ natsort($aTRs); $table .= implode("", $aTRs); } }//booker list $table .= "<tr><th colspan='3' style='text-align:right'>Total Attendees so far</th><td><b>$atendeesNo</b></td></tr>"; reset($bookerList); if(!$lister || !$bookerList) echo "<p><b>Sorry, nobody is yet attending...</b></p>"; else echo "<table><caption><h3>People Attending</h3></caption>\r\n" . $table . "</table>"; } ?>
Forgot:
Of course you need to place the code in the overriding placeholder template as it is actually documented in the top of my code:
/wp-content/themes/twentyten/plugins/events-manager/placeholders/attendees.phpI just load the above code from my personal plugin, so the template in the theme is just a passthru to my code
i guess in a future v5 update (not immediately) I’ll add more booking placeholders that can be used not only in emails but other areas too (like a format for the #_ATTENDEES placeholder)
Thanks so much! Your code works brilliantly. I did notice that cancelled bookings count towards the total in your code, but it looks like you’re using the number from $EM_Booking->spaces, so I assume that’s the fault of the plugin and not your code.
Glad I was of help. Also thanks for spotting the cancellation issue. Not very critical in my case, but gonna look into it.
cheers
Just stumbled across your code, and it’s great! Does almost exactly what I want, and I was able to modify it somewhat to be even closer! Now, I have one question for either you or @marcus: I’d like to have the ticket name and or ticket description appear in the table, but I have no idea what the variable names would be for those items. Could either of you help?
Thanks!
Hi
fine that my code helps a few out there. I am happy.
$EM_Ticket = $EM_Ticket_Booking->get_ticket();
gets the ticket (we are going through all the bookings of a user)Without having checked details, I assume that I could get a bookings with different tickets_
– Booking 1 (Ticket ID 1)
– Booking 2 (Ticket ID 2)
– Booking 3 (Ticket ID 1)
– Booking 4 (Ticket ID 4)
…In the Ticket Object you will find
$EM_Ticket->output_property("name") or $EM_Ticket->name
(per row)
I think (I never use multiple tickets) I should look into grouping the attendees table by tickets rather than mixing in table all tickets.
If you got improved code, perhaps you can post it as well ?
thanks for sharing.
@shonu: Thanks for your insights. As it turns out, what I was looking for was already in your original code — just commented out — the
$EM_Ticket->name
was, well, just the ticket! (Pardon the pun).Thanks again!
@shonu or someone else.
I’m pretty lost on where to put the code.
I have moved the folders and filed to my themes folder.
I understand that I need to modify the attendees.php file.Can anyone please guide me how to do this.
I just want a list of usernames of the people booked to an event.
- The topic ‘[Plugin: Events Manager] Display attendees in a page’ is closed to new replies.