WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. johanlwc
    Member
    Posted 2 years ago #

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

  2. lazyazian
    Member
    Posted 2 years ago #

    In trying to modify the attendees.php file, I use the 2 versions from big_raji and Shonu, but each time I only get 1 attendee showing up on the page even though there are a number of attendees. Since both sets of code is only showing 1 attendee, I'm assuming it's the Events Manager plugin's issue?

    Can someone help me look through the 2 versions of code as I'm not a php programmer, but I can get the gist of it. Everything looks right. Just in case it is the code below.

    Big_raji 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;
    }
    ?>
    <ul class="event-attendees">
            <?php foreach($people as $EM_Person): ?>
                    <li><?php echo get_avatar($EM_Person->ID, 50); ?></li>
            <?php endforeach; ?>
    </ul>

    Shonu Code:

    <?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>Name</th>"
    //                        ."<th>Time registered</th>"
    //                        ."<th>Status</th>"
                            ."<th>Mashers</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:#FFFFFF;'":"")."><!-- $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'></th><td><b></b></td></tr>";
    //   $table .= "<tr><th colspan='3' style='text-align:right'>Total RSVPs so far</th><td><b>$atendeesNo</b></td></tr>";
       reset($bookerList);
       if(!$lister || !$bookerList)
          echo "<p><b>No RSVPs yet...</b></p>";
       else
    	  echo "<table><caption><h3></h3></caption>\r\n" . $table . "</table>";
    //     echo "<table><caption><h3>People Attending</h3></caption>\r\n" . $table . "</table>";
    
    }
    ?>

    Thanks!

  3. agelonwl
    Member
    Posted 2 years ago #

    @lazyazian

    both of the code works for me; showing all attendees. Also, Does the default template do the same? can you try to turn-on WP_DEBUG.

  4. lazyazian
    Member
    Posted 2 years ago #

    @agelonwl - Thanks for checking! I was actually able to get it working too. I forgot what I had done, but I was able to finally get them both to show all the attendees.

    I wish I knew how to code more because I wanted to combine both of the codes to show both the name and avatar of the attendee. But I couldn't figure out how to get them both working in a nice table format with the name above the avatar.

    Reasoning is that I noticed that if someone just has a default avatar, other people don't know who the attendee is according to the avatar. And there's no "alt" so that if I hover over the avatar, the name comes up. So I tried to create a table and put the name above the avatar. Didn't work though as a carriage return (\n\r or
    ) within a <td> didn't work. I was only able to get the names next to the avatars (like how it's displayed here).

    I think I had just too high demands for a pseduo-coder like me. Wanted the avatars (with names on top of the avatars) in a row, instead of a long, single column heh.

  5. yarf
    Member
    Posted 1 year ago #

    okay I know I digging up a old topic but hope someone can help. for one of the sites I maintain i can't get either of the suggested codes to work i have been using shoun code and copy and pasted in notepad and made no changes. i got it to work on two other sites just fine. this is the error i get on the third.

    Fatal error: Cannot redeclare showbookingstable() (previously declared in /home/lvtriclu/public_html/wp-content/plugins/events-manager/templates/placeholders/attendees.php:12) in /home/lvtriclu/public_html/wp-content/plugins/events-manager/templates/placeholders/attendees.php on line 107

    the two i got it to work on is with my webhosting provider (1and1) and the one it doesn't work on is a web hosting company that donate space to the club. I'm lost on how to get the code to work on this site and the club board would like this feature and can't understand why i haven't enable it on their site yet. so any tips or suggestions on how to get it to work would be helpful.

    Cheers,
    Yarf

  6. agelonwl
    Member
    Posted 1 year ago #

    @yarf

    can you re-open this ticket in a new thread?

  7. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    @yarf, showbookingstable() isn't an em function, looks like you modified your template

  8. Shonu
    Member
    Posted 1 year ago #

    showbookingstable() is the function I have used for my solution.

    Either this name has been given by another plugin co-incidentally, or you have two plugins installed that contain this workaround.

    I personally, have added the actual function to my priva<te plugin and in the themes folder file just added

    <?php include(WP_PLUGIN_DIR ."/CSCOverrider/includes/events-manager/placeholders/attendees.php"); ?>

    where the actual function is coded

  9. the red bicycle
    Member
    Posted 1 year ago #

    It looks as if I am on the right path..attendees.php but what code do I need to add to have conditional placeholder that will only show if I don't have attendees?

    Any thoughts?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic