Support

Home Forums Event Espresso Premium Attendee Gravatar Shortcode

Attendee Gravatar Shortcode

Posted: September 27, 2016 at 10:32 pm


gdtech

September 27, 2016 at 10:32 pm

I liked the idea of showing who is coming to our event so I used [ESPRESSO_EVENT_ATTENDEES status=status=RPP show_gravatar=true] in a widget and edited content-espresso_event_attendees.php to remove ti <li> and the attendee name. It works perfectly and looks great. However, I’m expecting over 1,000 attendees. Is there a way to limit how many Gravatars show in my widget??

I followed your instructions for editing the following:
How to customize the Attendee list templates
General Instructions
Step 1: Copy the espresso_event_attendees.php templates from the /event-espresso-core-reg/public/Espresso_Arabica_2014/ folder to your WordPress child theme’s folder.
The two templates’ names are loop-espresso_event_attendees.php & content-espresso_event_attendees.php
Step 2: Make your modifications to the templates that you copied to your theme.

  • This topic was modified 7 years, 7 months ago by  Tony. Reason: Code formatting


Tony

  • Support Staff

September 29, 2016 at 5:02 am

Hi there,

Currently you can not limit the query used to pull in the contacts for the above shortcode, you can skip stop outputting the details to the page after X amount but the query would have still pulled those details in.

Other than building out your own query rather than using the shortcode I can’t see another way to limit the results, I’ll check with our developers to see if I’m missing anything.


gdtech

September 29, 2016 at 5:14 am

Thanks for the reply. You said, “you can skip stop outputting the details to the page after X amount but the query would have still pulled those details in.” How would I do that?


Tony

  • Support Staff

September 29, 2016 at 5:58 am

You would use a loop within loop-espresso_event_attendees.php

Before the foreach loop setup a counter, for example $i = 0

After the contact has been output within the foreach loop increment the counter with $i++;

Then after that check if the counter is equal to the amount of contacts to display and if so, break the loop: if( $i == 100) {break;}

Something like this should work:

$i = 0;

foreach( $contacts as $contact ) {
	EEH_Template::get_template_part( 'content', 'espresso_event_attendees', array( 
	'contact'       => $contact, 
	'event'         => $event,
	'datetime'      => $datetime,
	'ticket'        => $ticket,
	'show_gravatar' => $show_gravatar 
	) );
	$i++;
	if( $i >= 100 ) { break; }
} 


gdtech

October 1, 2016 at 9:33 am

I couldn’t get it to work…but on a more basic level, now the shortocode doesn’t work at all. I removed all my work and started from scratch and no matter what I do, it says “No Attendees Yet.” I have multiple registrations both approved and pending payment and no matter what combination if codes I use, nothing works. Thoughts?


gdtech

October 1, 2016 at 11:08 am

Ignore my last reply. I got it to work. And I got your loop to works. It works great. However, it doubles the output.

So, on content-espresso_event_attendees.php, I’ve got the following code:

if ( $show_gravatar ) {
	$gravatar = get_avatar( $contact->email(),
		(int) apply_filters( 'FHEE__loop-espresso_attendees-shortcode__template__avatar_size', 32 )
		);
} else {
	$gravatar = '';
}
?>

<?php echo $gravatar?>

On loop-espresso_event_attendees.php, I’ve got the following code:


$no_attendees_message =  apply_filters( 'FHEE__loop-espresso_attendees-shortcode__template__no_attendees_message', __('No Attendees Yet', 'event_espresso' ) );

$i = 0;

foreach( $contacts as $contact ) {
	EEH_Template::get_template_part( 'content', 'espresso_event_attendees', array( 
	'contact'       => $contact, 
	'event'         => $event,
	'datetime'      => $datetime,
	'ticket'        => $ticket,
	'show_gravatar' => $show_gravatar 
	) );
	$i++;
	if( $i >= 300 ) { break; }
} 

?>
<div class="event-attendees">
	<?php do_action( 'AHEE__loop-espresso_event_attendees__before', $contacts, $event, $datetime, $ticket, $show_gravatar ); ?>
	<?php if ( $contacts ) : ?>
		<ul class="event-attendees-list">
			<?php foreach( $contacts as $contact ) :
				EEH_Template::get_template_part( 'content', 'espresso_event_attendees', array( 
					'contact'       => $contact, 
					'event'         => $event,
					'datetime'      => $datetime,
					'ticket'        => $ticket,
					'show_gravatar' => $show_gravatar 
				) );
				endforeach; ?>
		</ul>
	<?php else : ?>
		<p><?php echo $no_attendees_message; ?></p>
	<?php endif; ?>
	<?php do_action( 'AHEE__loop-espresso_event_attendees__after', $contacts, $event, $datetime, $ticket, $show_gravatar ); ?>
</div>

Here’s the output:

https://lh6.googleusercontent.com/IYdn6FQuQ5CpPL5IQ7njVe8WMiCCsxlm1qKg6IabdNojT4zjoCdE1k6qhWVGpgMyeVFcabD_EV_k_lw=w1356-h618

  • This reply was modified 7 years, 6 months ago by  Tony. Reason: Code formatting


gdtech

October 1, 2016 at 9:15 pm

Hehehe. Never mind. I’ve got it all figured out. Have a good weekend! Thanks.


Tony

  • Support Staff

October 4, 2016 at 3:36 am

Looks like you had the code to output the contact details twice within the file but its hard to tell with the code formatting on the forums.

If posting code it much better to use something like http://pastebin.com/ and then including the URL here for us to view.

Anyway, I’m glad you have it figured out 🙂

The support post ‘Attendee Gravatar Shortcode’ 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