Support

Home Forums Event Espresso Premium Front end attendee list page EE4?

Front end attendee list page EE4?

Posted: July 4, 2014 at 6:02 am

Viewing 4 reply threads


Colin Spencer

July 4, 2014 at 6:02 am

Is it possible to create a page that lists all registered attendees to an event on the front end. I want to show this via a password protected page to some of my site members.


Dean

July 4, 2014 at 6:18 am

Hi,

This page contains some code snippets: https://eventespresso.com/wiki/useful-php-code-snippets/

You could use the “Print an attendee list after the content on the event details page” and modify it so that it would work from a shortcode instead of a function.

Something like this could be added to your themes functions.php or a custom files plugin:

add_shortcode('display_those_attendees', 'ee_attendee_list' );
 
function ee_attendee_list($atts){
    global $wpdb, $post;

$EVT_ID = $atts['eventid'];
$post = get_post( $EVT_ID );   

        echo '<ul class="attendee-list">';
    
        $sql = "SELECT ATT_fname, ATT_lname, ATT_email ";
        $sql .= "FROM {$wpdb->prefix}esp_attendee_meta ";
        $sql .= "INNER JOIN {$wpdb->prefix}esp_registration ";
        $sql .= "ON {$wpdb->prefix}esp_attendee_meta.ATT_ID = {$wpdb->prefix}esp_registration.ATT_ID ";
        $sql .= "WHERE {$wpdb->prefix}esp_registration.EVT_ID = %d";
        
        $attendees = $wpdb->get_results( $wpdb->prepare( $sql, $post->ID ));

        foreach($attendees as $attendee){
            $fname = $attendee->ATT_fname;
            $lname = $attendee->ATT_lname;
            $email = $attendee->ATT_email;
            $gravatar = get_avatar( $email, '64', 'identicon' );
            $html = '<li>'. $gravatar .'<span>'. $fname .' '. $lname . '</span></li>';
            echo $html;
        }
    
        echo '</ul>';

return;

}

Then add the shortcode [display_those_attendees eventid=”83″] into a password protected page.


Colin Spencer

July 4, 2014 at 7:23 am

Dean,

Thanks for the code it works perfectly I have removed the Gravatar BUT it even shows those who have cancelled is there a way to exclude those?


Tony

  • Support Staff

July 4, 2014 at 9:12 am

On line 15 of that snippet you’ll find

$sql .= "WHERE {$wpdb->prefix}esp_registration.EVT_ID = %d";

Add a space after %d and then under that add:

$sql .= "AND {$wpdb->prefix}esp_registration.STS_ID = 'RAP'";

That will then only pull Approved registrations from the DB.

Does that help?


Josh

  • Support Staff

July 9, 2015 at 8:15 am

Update: Event Espresso 4 now includes an Attendee List shortcode that you can use instead of the code snippet.

[ESPRESSO_EVENT_ATTENDEES]

Here’s a link to its documentation:

https://eventespresso.com/wiki/ee4-shortcodes-template-variables/#event-attendees

Viewing 4 reply threads

The support post ‘Front end attendee list page EE4?’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso