Posted: November 21, 2018 at 4:39 am
|
I would like to display all registrations for a family, so I’m looking for a way to pass a list of related attendee IDs and then retrieve the events and display them together all in one table, sortable by attendee or by event name. Can I edit the ESPRESSO_MY_EVENTS shortcode template (loop-espresso_my_events-event_section.template.php) to essentially loop over all the registrations for the current user but also repeat for a list of att_ids I provide? Or do I need to modify or extend the shortcode itself? If I need to modify the shortcode, I see there are multiple files for the same shortcode, so I’m confused about which one to edit, and of course, I don’t want to overwrite the actual add-on code. So can I do it with hooks from my own custom plugin function? Also, I would like to show the following additional columns for the MY_EVENTS output: Can you help me with a code snippet to retrieve that information? Thanks! |
|
I have been reading the support posts and documentation, and I am wondering if I can somehow achieve the changes I need to make with a filter hook? Also, will any of the helper templates point me in the right direction? I don’t see an EEH_Registrations.helper.php, but maybe a combination of the EEH_Event_View and other helpers will somehow? I will go start reading the code… |
Hi there,
With regards to the actual template file itself, yes you can, most template files can simply be placed within your themes root directory to override the default template file. If you’re not using a custom theme specifically for your site, we recommend creating a child theme and placing them within that. Looping over the registrations of the current user and the add_id’s you provide is also possible, you’ll basically need to re-pull all of the registration you need from the database and override what the shortcode has already done for you. Note that it is possible to pull registrations for known ATT_ID’s using our model system, have you read through any of the documentation for the models? If not, take a look here: https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System Generally, we don’t provide snippets for customizations but we can help point you in the right direction, for example you can use the models like this:
Which would pull in all of the registrations for ATT_ID 918 and 234…. BUT if you’re looking to pull registrations for a specific event and known ATT_ID’s, you use a completely different model, so understanding how our model system works is important.
Template files or others? Whilst it may not appear so at first glance, the shortcode is actually pulling in a lot of data and covering a lot of different setups at once, which is why it breaks everything down it multiple templates (to help users modify the specific sections they need to). It depends on the exact changes you want to make as to how you do it.
Are you using the default event_section template or simple_list_table? (If you don’t know it’ll be the event_section, as you have to add a shortcode parameter to load the simple_list_table. Within which section, I’m guessing in the ‘Your tickets section? I think it would be best to work out how to get all of the registrations/events you need first before trying to work through additional customizations.
The helper functions are essentially a set of files used for common tasks, the EEH_Event_view helpers pull information for the event, not registrations, and whilst you could use those for some of your data, your wanting data relating to specific registrations, which you wont get from some of the helper files. For example, you mentioned start date, class time and day of the week above but those aren’t actually in relation to the event anymore, because an event may have multiple datetimes, so you can use something like this:
To just pull the next datetime from the event, because that may not be the datetime the registration was made on… make sense? |
|
|
Thanks for that code snippet! I have a custom plugin and a custom shortcode, and I have retrieved my array of ATT_IDs and then used the snippet you provided, but the call on the EEM_Registration is coming back with an empty result. Here is the code: $attids = $wpdb->get_col($wpdb->prepare("SELECT distinct attendee_id as ATT_ID FROM ". EVENTS_MEMBER_REL_TABLE . " WHERE user_id = '%d'", $userid), 0); // now get registrations for those ATT_IDs $where = array('ATT_ID' => array('IN', $attids),); $registrations = EEM_Registration::instance()->get_all(array($where)); That comes back with no results. However, if I just define the array manually like this: $attids = array(15490, 15614, 16229); Then I get results. I don’t understand why the array returned by get_col is different than the hard-coded non-indexed one, they look identical when I output them with print_r(). I tried looping over the results and reformatting them as a comma-delimited string and using that to build the array, but no luck. What am I doing wrong? I’m sure it’s something really obvious… |
Do |
|
|
I figured it out! It was weird, because first I found that I needed to wrap it in another array() like this: $where = array('ATT_ID' => array('IN', array($attids)),); but then after reloading the page a few times, the registrations stopped showing up again, so I removed the array wrapper, and now it works fine without it. I also figured out how to display the other fields, except I do still some questions: <?php EEH_Template::locate_template( 'status-legend-espresso_my_events.template.php', array('template_slug' => 'simple_list_table'), true, false ); ?> </div> <?php do_action('AHEE__loop-espresso_my_events__after', '', array(), 'simple_list_table', $userid); ?> and |
1) how can I get the legend on my page that is on the my_events templates. I’m sorry, but I don’t follow. What are you trying to do? The legend should display regardless, you should need to copy the additional code over (unless you previously removed it?) Can you add a screenshot of what you see, and what you are trying to acheieve? https://eventespresso.com/wiki/troubleshooting-checklist/#screenshots
Why are you overriding Where is
I’d use:
for pretty_status the first param is the status, second is if its plural and used for translation, last is the schema to apply: ‘upper’ = uppercase |
|
|
Thanks, that’s just what I needed for the registration status! I ended up just copying the relevant HTML of the legend because I only wanted to display part of it anyway. Another question: is $ticket->price() the actual amount they paid, including any discounts? |
If you let me know what you are trying to do I can let you know how to do it the ‘correct’ way (if there is one).
No, it’s the price from the ticket object. Do you want the total from the transaction (total amount paid across all registrations?) If so thats Or the total a\mount paid per registration? |
|
The support post ‘display registrations for multiple attendees in ESPRESSO_MY_EVENTS 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.