WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Display attendees in a page (39 posts)

  1. ZyberFart
    Member
    Posted 2 years ago #

    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.

    http://wordpress.org/extend/plugins/events-manager/

  2. agelonwl
    Member
    Posted 2 years ago #

    You can try to put this placeholder #_ATTENDEES in the single events page Settings > Events Format > Default single event format. Is this the area that you want to use it?

  3. Shonu
    Member
    Posted 2 years ago #

    I had done my personal view of the table (in a small variation soon, I need to make sure, that only Editors and admins get this table rendered)

    I'd love if this table could be made configurable, column by column and view controlled globally for defaults but overridable for each event (there might be cases where you want to show all who is attending, not only editors/admins)

  4. ZyberFart
    Member
    Posted 2 years ago #

    agelonwl,

    Thanx for response. No, not quite, I would like to have just a standard WP-page called Attendess that lists who's attending to the event.

  5. ZyberFart
    Member
    Posted 2 years ago #

    Or the best would to have a widget that lists the attendees.

  6. Shonu
    Member
    Posted 2 years ago #

    Something like [em-attendees id=<event id>] ?

    I also like the widget idea as a widget would know if an event is displayed and then display attendees (you may choose if for specific events or on page scope)

    Nice to have

  7. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    you can use this:

    [event event=id]#_ATTENDEES[/event]

    and then modify the attendees template

  8. Shonu
    Member
    Posted 2 years ago #

    I totally forgot that the scop of "#_" notation can be set using this encapsulation - good one!

  9. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    actually, i need to update the docs, a recent-ish feature :)

  10. ZyberFart
    Member
    Posted 2 years ago #

    Yepp, seems to work even though I just get a bullet list and no names, at least not visible. I gather I have to do some modification in the css as well ??

  11. big_raji
    Member
    Posted 2 years ago #

    Is there a way to get names in there instead of avatars? I tried editing the attendees.php file in the /templates/placeholders directory, but I have no clue how to edit it.

    I tried changing "get_avatar" to "get_name" with no luck, and also trying to change/delete the parameters in the bracket. It just causes the event page to return a completely blank page.

    Here's the code in question:

    <?php
    /* @var $EM_Event EM_Event */
    $people = array();
    foreach($EM_Event->get_bookings() as $EM_Booking){
            $people[$EM_Booking->person->ID] = $EM_Booking->person;
    }
    ?>
    <ul class="event-attendees">
            <?php foreach($people as $EM_Person): ?>
                    <li><?php echo get_avatar($EM_Person->ID, 50); ?></li>
            <?php endforeach; ?>
    </ul>
  12. big_raji
    Member
    Posted 2 years ago #

    Well, I think I figured some stuff out. Here's my adjusted attendees.php
    (forgive me for any formatting errors. I'm not a programmer at all)

    <?php
    /* @var $EM_Event EM_Event */
    $people = array();
    foreach($EM_Event->get_bookings() as $EM_Booking){
            $people[$EM_Booking->person->ID] = $EM_Booking->person;
    }
    ?>
    <ul class="event-attendees">
            <?php foreach($people as $EM_Person): ?>
            <li>
            <?php $user_info = get_userdata($EM_Person->ID);
            echo $user_info->first_name . " " . $user_info->last_name . " - Spaces: " . $EM_Booking->get_spaces();
            ?></li>
            <?php endforeach; ?>
    </ul>
  13. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    one suggestion, $EM_Person is actually a WP_User class extended, so instead of setting $user_info, you can directly use $EM_Person->first_name etc.

    btw, just learnt this yesterday, you should start using ->user_firstname, ->user_lastname as the other two are depreciated.

  14. big_raji
    Member
    Posted 2 years ago #

    I have no idea what that means, but I will give it a try. ;) thanks!

    Slightly off topic, but the $EM_Booking->get_spaces() just returns a "1" no matter what. I want it to echo the number of spaces booked by the person, but I guess it's grabbing the wrong number from somewhere. Do you have any hints on that?

  15. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    that should be right, are you sure you don't have the wrong booking object? you can access the property directly by ->spaces (but not recommended)

  16. big_raji
    Member
    Posted 2 years ago #

    Sorry, as I said, I'm not a programmer so I don't even understand your question. My code is exactly as I posted in the above message, and I have the #_ATTENDEES tag in the "Default single event format" area within the {has_bookings} tag.

    It definitely returns all "1" for the spaces, even though some people signed up for 2 or 3 spots. If I change my booking to "2" spaces, it will show all "2" for everybody's spaces. If I logout and login again, and keep my booking at "2", it shows all "1" again. I've ctrl-refreshed many times and cleaned out my wp-cache each time I refreshed the page.

  17. arizonai
    Member
    Posted 2 years ago #

    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; ?>
  18. arizonai
    Member
    Posted 2 years ago #

    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.

  19. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    that's because your first foreach loop is setting $EM_Booking and reused in the second one.

  20. big_raji
    Member
    Posted 2 years ago #

    @arizonai - did you ever make any more progress on your code?

  21. theurbanbrain
    Member
    Posted 2 years ago #

    @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?

  22. Shonu
    Member
    Posted 2 years ago #

    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>";
    }
    ?>
  23. Shonu
    Member
    Posted 2 years ago #

    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.php

    I just load the above code from my personal plugin, so the template in the theme is just a passthru to my code

  24. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    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)

  25. big_raji
    Member
    Posted 2 years ago #

    @Shonu

    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.

  26. Shonu
    Member
    Posted 2 years ago #

    @big_raji

    Glad I was of help. Also thanks for spotting the cancellation issue. Not very critical in my case, but gonna look into it.

    cheers

  27. gerenm
    Member
    Posted 2 years ago #

    @Shonu

    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!

  28. Shonu
    Member
    Posted 2 years ago #

    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 ?

  29. agelonwl
    Member
    Posted 2 years ago #

    thanks for sharing.

  30. gerenm
    Member
    Posted 2 years ago #

    @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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic