Support

Home Forums WP User Integration User not seeing registrations with [ESPRESSO_MY_EVENTS]

User not seeing registrations with [ESPRESSO_MY_EVENTS]

Posted: November 19, 2016 at 1:45 pm


bmarolf

November 19, 2016 at 1:45 pm

So I manage a community website where members register their children for events, and I understand from reading other threads that if the member changes the name of the primary registrant, it will not show up using [ESPRESSO_MY_EVENTS]

Is there a workaround for this? Or some code snippet that would allow the logged in user to register someone in a different name or email and have the registration show up in their “My Event Registrations”? This is a major issue for this organization and I’d be willing to hire a developer to accomplish this if needed.


bmarolf

November 23, 2016 at 12:19 pm

No one? I’d really like some help on this if anyone has any advice.


Josh

  • Support Staff

November 23, 2016 at 12:46 pm

The workaround that doesn’t involve any custom coding is you add a new field to the registration form for the actual attendee name. So you’ll still capture the registrant/contact person’s info (the person who completes the registration form while logged into the website), then additionally the form can capture the information about the person who will be attending.


bmarolf

November 25, 2016 at 6:43 am

Thanks for the reply Josh. I tested that solution, adding “Attendee First Name” and “Attendee Last Name” to the registration form. I changed the required first name and email address to “Parent First Name” and “Parent Email Address”.

This solves the problem in now it shows up in their event registrations (as long as they don’t change the Parent info.

Is there a way to make those fields read-only?

The only other problem is now when I use the shortcode [ESPRESSO_EVENT_ATTENDEES], it will only show the Parent’s info, not the Attendee’s info. Its there a way to change that?

Thanks!


Josh

  • Support Staff

November 25, 2016 at 10:46 am

I’ll try to keep the replies in this thread organized by following up with two separate replies to your questions.

Is there a way to make those fields read-only?

Those fields can be made read-only by injecting some JavaScript onto the page that targets those specific fields to make them read only. Here’s a link to a gist that has some example code:

https://gist.github.com/joshfeck/abebd6fb3cdc796bf1f913de6c6d1816

You can add the above to a functions plugin or into your WordPress theme’s functions.php file.


Josh

  • Support Staff

November 25, 2016 at 7:22 pm

The only other problem is now when I use the shortcode [ESPRESSO_EVENT_ATTENDEES], it will only show the Parent’s info, not the Attendee’s info. Its there a way to change that?

Yes there is a way and it involves modifying some of the PHP code in the content-espresso_event_attendees.php template. There are some instructions on how to modify this template in our documentation:

https://eventespresso.com/wiki/ee4-shortcodes-template-variables/#custom-attendee-list


bmarolf

November 28, 2016 at 9:05 am

Thanks Josh! The read-only worked just fine.

About the custom attendee list, I copied content-espresso_event_attendees.php into my themes folder and I can modify it, but the line of code that displays the contact’s name is this:

  • <?php echo $gravatar . ‘ ‘ . $contact->full_name(); ?>
  • How do I change that to display the Attendee, not the Contact? (logged in user)

    Thanks!


    bmarolf

    November 28, 2016 at 9:06 am

    oops the line of code is
    <li><?php echo $gravatar . '&nbsp;' . $contact->full_name(); ?></li>


    Josh

    • Support Staff

    November 28, 2016 at 2:52 pm

    The exact code that you’ll use depends on which field(s) you’re using to capture the attendee information. The code example that’s linked up in the documentation shows how to add the value of a field from the registration form. So you can reuse the code from that example, and change the ID that’s used the example to get the field for the attendee name. Then you change the part of the code where it outputs by removing the $gravatar . '&nbsp;' . $contact->full_name() and replace with the attendee name data.


    bmarolf

    December 1, 2016 at 9:10 pm

    Thanks again Josh – that worked. I see that if the logged in user registers more than 1 attendee, it only shows 1 of them using [ESPRESSO_EVENT_ATTENDEES]. Do I need to do something with loop-espresso_event_attendees.php?


    Josh

    • Support Staff

    December 2, 2016 at 7:37 am

    Yes for sure.


    bmarolf

    December 2, 2016 at 9:08 am

    Care to elaborate on what mods I need to make?


    Josh

    • Support Staff

    December 2, 2016 at 7:18 pm

    I’m not sure exactly what mods you need to make, because the mods you will need to make will depend on some factors like if they’re registering for multiple events, or more than one time per event. I can point out a few ways to break things down a bit, but in the end it may be better to not use the short code for this, and instead build your own short code, or even inject the template via a hook.

    So one way to achieve what you’re out to to is run a secondary loop based on the registrations within that transaction for that contact. That loop can be run in the loop-espresso_event_attendees.php template. Right after the loop starts, you first grab all the related registrations for that event:

    $registrations = $contact->get_many_related('Registration',
                array(array('EVT_ID' => $event->id())));

    then you can start another loop:

    foreach($registrations as $registration ) :
    // call to EEH_Template::get_template_part() here
    endforeach; //end inner loop
    endforeach: //end outer loop

    There are a few downsides to this method, one being that if they’ve registered more than one time, you’ll end up with some repeats in the list (because it will loop through all of their registrations in that event). The other downside is you’ll need to modify the content-espresso_event_attendees.php template so it can loop through the answers the custom questions.

    Which, actually, if you look at the example code for the content- template, there’s a limit set to 1. You may be able to get away with raising that limit which will then output more than just attendee name, without modifying the loop file.

    The thing I don’t like about any of the above is it’s going to take a significant amount of work to make the short code do something it wasn’t designed to do. Instead of doing the above, I can suggest doing a simple query on the database and output the list using an action hook. Here’s a simplified example that should get you on the right path:

    https://gist.github.com/joshfeck/322566085d07254c94b55ed6fcb40c23


    bmarolf

    December 5, 2016 at 8:01 am

    Josh, thanks very much for the detailed explanation. I agree that it would take a significant amount of work to get it right. I think your suggestion about doing the simple query is best. I want to make it show only approved Registrations, so I added this to the bottom of the query:

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

    But it doesn’t seem to work. Am I doing something wrong?


    bmarolf

    December 5, 2016 at 8:58 am

    I moved it up to be just before the bottom line of the query and it seemed to work. Thanks Josh.


    Josh

    • Support Staff

    December 5, 2016 at 9:39 am

    Yeah that looks like a happy accident that it works by moving it up one line. The part you may have missed when you added the additional line to the end was you probably needed to add a space to the end of query on the former last line.

    So another way to fix it would be add a space like in the following:

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


    bmarolf

    December 5, 2016 at 1:50 pm

    Ahhh, I see what you did there. 🙂 Thanks for all your help.

    The support post ‘User not seeing registrations with [ESPRESSO_MY_EVENTS]’ 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