Support

Home Forums Event Espresso Premium Attendee list show username instead of full name

Attendee list show username instead of full name

Posted: December 17, 2015 at 8:46 am

Viewing 3 reply threads


SupercarDriver

December 17, 2015 at 8:46 am

Hi everyone,

Tried to search before posting but haven’t been able to find anything.

How would I change the way that the ‘show attendees’ shortcode displays full name? I instead would like it to just display the username of the person who is attending.

I can see the following code in (content-espresso_event_attendees.php):
$contact->full_name();

I’m pretty sure this is where I would change it but I’m unsure what to change this to in order to get back usernames instead of full names?

Thanks for any help!
Oliver


Tony

  • Support Staff

December 17, 2015 at 11:38 am

Hi Oliver,

I’m assuming all of your registrations are made by logged in users?

Do you use the EE4 User Integration add-on?

Can users register multiple attendees onto the event?

You could use something like this:

$user_id = $contact->wp_user();
$user = get_user_by( 'id', $user_id );
if ( $user instanceof WP_User ) {
	echo $user->user_nicename;
}

However it may not work with all setups, especially if you allow non members to register, you’ll need to do some additional checks if that’s the case.


SupercarDriver

December 17, 2015 at 12:36 pm

Hi Tony,

Thank you for the reply! Yes EE4 user integration is installed and the events are only visible to logged in users. I tried that code but it doesn’t seem to be displaying the correct user. It seems to be displaying a different users username with the number 2 in front of it.

One thing I did notice though was that the Gravatar has the correct username in it’s alt tag, but i’m unsure how that’s generated to try and take the same code.

Would really appreciate any further help you could offer.

Thanks again!


Tony

  • Support Staff

December 18, 2015 at 4:24 am

Hmm, I have no idea where the number 2 is coming from, but I’ve altered the code to pull in the user based on the email address of the contact. If no user can be found for that email it outputs the contact details as it normally would.

Take a look at this: https://gist.github.com/Pebblo/7bce6b7bf46e20d3e838

That should then show the username for an account with the same email address used to create that contact.

Viewing 3 reply threads

The support post ‘Attendee list show username instead of full name’ 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