Support

Home Forums Event Espresso Premium [ESPRESSO_EVENT_ATTENDEES] – want more info than just the person's name

[ESPRESSO_EVENT_ATTENDEES] – want more info than just the person's name

Posted: August 14, 2018 at 1:51 pm

Viewing 15 reply threads


DonBrown

August 14, 2018 at 1:51 pm

I want to add more than just the person’s name on a page using the shortcode: [ESPRESSO_EVENT_ATTENDEES]

Since I am not a developer, is there a way of doing this without having to write PhP?

For example, can we add a parameter within the shortcode, say for example, the Website of the person? (assuming they provided their website when they registered.)

Thanks for your help,
Don


Josh

  • Support Staff

August 14, 2018 at 1:58 pm

Hi Don,

I checked and I’m afraid parameters like those do not exist:

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

The above link to the documentation does include some information about how to customize the templates using PHP. If you can team up with a PHP developer then the example outlined in the documentation can be followed.


DonBrown

August 14, 2018 at 3:52 pm

Hi Josh

Thanks for the reply.

From your documentation:

How to customize the Attendee list templates

Step 1: Copy the espresso_event_attendees.php template from the /event-espresso-core-reg/public/Espresso_Arabica_2014/ folder to your WordPress child theme’s folder.

The main template’s name is content-espresso_event_attendees.php. If you need to modify the loop, you can copy loop-espresso_event_attendees.php.

Step 2: Make your modifications to the templates that you copied to your theme

Can we use PhP Plugins like: PHP code snippets (Insert PHP)
https://wordpress.org/plugins/insert-php-code-snippet/
or similar, to add PHP to content-espresso_event_attendees.php file?

Thanks,
Don


Josh

  • Support Staff

August 14, 2018 at 4:04 pm

No the plugins like those do not work with the templates. Instead you add PHP directly into the template file in the child theme folder.


DonBrown

August 14, 2018 at 4:37 pm

Josh

If the theme is updated, do we lose the manually entered PhP code?

Thanks,
Don


Josh

  • Support Staff

August 14, 2018 at 8:49 pm

Hi Don,

The documentation says to use a child theme. So when the parent theme is updated, you will not lose your changes. There’s more information about why to use child themes in the WordPress codex:

https://codex.wordpress.org/Child_Themes


DonBrown

August 16, 2018 at 9:21 am

Hi Josh

OK – I have copied the content-espresso_event_attendees.php to the theme and inserted the code below for reference.

Just to see if it worked, I copied the line of code:

  • <?php echo $gravatar . ‘ ‘ . $contact->full_name(); ?>
  • and it worked as expected. It displayed the contact name twice.

    Question – what line of PhP code should I add to include the Website and Email address of the person who registered for the event?

    Thanks for your help,
    Don
    ———————————
    <?php
    /**
    * Content Template for the [ESPRESSO_EVENT_ATTENDEES] shortcode
    *
    * @package Event Espresso
    * @subpackage templates
    * @since 4.6.29
    * @author Darren Ethier
    *
    * Template Args that are available in this template
    * @type EE_Attendee $contact
    * @type bool $show_gravatar whether to show gravatar or not.
    */
    if ( $show_gravatar ) {
    $gravatar = get_avatar( $contact->email(),
    (int) apply_filters( ‘FHEE__loop-espresso_attendees-shortcode__template__avatar_size’, 32 )
    );
    } else {
    $gravatar = ”;
    }
    ?>
    <?php do_action( ‘AHEE__content-espresso_event_attendees__before’, $contact, $show_gravatar ); ?>

  • <?php echo $gravatar . ‘ ‘ . $contact->full_name(); ?>
  • <?php echo $gravatar . ‘ ‘ . $contact->full_name(); ?>
  • <?php do_action( ‘AHEE__content-espresso_event_attendees__after’, $contact, $show_gravatar ); ?>


    Josh

    • Support Staff

    August 16, 2018 at 9:33 am

    Hi Don,

    For the answer to the website question, you’ll follow this example:

    https://gist.github.com/joshfeck/63fe625950c9a71e19be

    You’ll note that you’ll need to change line 19 to match your website question’s ID.

    Then, $contact->email() will get you the email address.


    DonBrown

    August 16, 2018 at 11:13 am

    Hi Josh

    Thanks – that worked.

    Another question – where can I find all of the available variables like: $contact->email() for the website, company name, etc.?

    Thanks,
    Don


    Josh

    • Support Staff

    August 16, 2018 at 11:38 am

    Hi Don,

    Since website, company name, etc. are not system questions, there are no variables for them. The reason there’s a method for the email address is because it’s a system question.


    DonBrown

    August 16, 2018 at 12:56 pm

    Hi Josh

    Sorry for the dumb questions:

    1. What are the “system question variables”? Or, where can I find them?
    2. Is there a way to display the non system question variables?

    Thanks for your continued help,
    Don


    Josh

    • Support Staff

    August 16, 2018 at 1:10 pm

    They’re not actually system question “variables”. They’re system questions and you can find the system questions in Event Espresso > Registration Form > Questions. The system questions are the questions that are added by default (First Name, Last Name, Email, and the Address questions).

    2. Is there a way to display the non system question variables?

    This example code shows an example of a way to display the non-system question answers:

    https://gist.github.com/joshfeck/63fe625950c9a71e19be


    GorgeousGetaway

    August 24, 2018 at 11:13 am

    Just to follow on with this question of ‘variables’
    Could you possibly let me know which variable would show a booking reference number?

    The tickets template has for e.g.
    echo $attendee instanceof EE_Attendee ? $attendee->full_name() : ”;

    I’d like the $attendee->Reference() if this exists?


    Josh

    • Support Staff

    August 24, 2018 at 11:44 am

    Hi,

    I’m not familiar with a booking reference number. Do you mean the registration ID, the reg. link URL, or the reg. code?


    GorgeousGetaway

    August 24, 2018 at 12:09 pm

    Hi, Sorry – Registration ID and the Registration Code please!

    Thanks


    Josh

    • Support Staff

    August 25, 2018 at 10:04 am

    You’ll actually need to loop through the registrations to get those. So for example your content-espresso_event_attendees.php template could look something like this:

    <?php
    
    $registrations = array();
    if ($contact instanceof EE_Attendee) {
        $registrations = EEM_Registration::instance()->get_all(array(
            array(
                'ATT_ID' => $contact->ID(),
                'EVT_ID' => $event->ID()
            ),
        ));
    }
    foreach($registrations as $registration ){
      if($registration instanceof EE_Registration){
        echo '<li>' . $contact->full_name() . ' ' 
        . ' &ndash; ' 
        . '<span style="color:#C0C0C0;">'
        . $registration->reg_code()
        . '</span>'
        . ' &ndash; ' 
        . '<span style="color:#707070;">'
        . $registration->get('REG_ID')
        . '</span></li>';
        
      }
    }
    Viewing 15 reply threads

    The support post ‘[ESPRESSO_EVENT_ATTENDEES] – want more info than just the person's 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