Support

Home Forums Event Espresso Premium How can I hide old events and sort by date the events a user has registered for?

How can I hide old events and sort by date the events a user has registered for?

Posted: February 12, 2020 at 12:26 pm

Viewing 1 reply thread


bmarolf

February 12, 2020 at 12:26 pm

Hello, I have this page on my website that a user can go to to see the events they have registered for. Only logged in users with registered events will see the content I will be referring to though. Here is that page: https://www.lighthousehomeschoolers.org/my-event-registrations/

I currently like everything on this page except:
1) events are showing in no sorted order (prefer: in order of date)
2) events that have passed are not hidden (prefer: only future events showing)

This page is using this shortcode:
[ESPRESSO_MY_EVENTS per_page=10 your_events_title=”Events You Registered For” your_tickets_title=”Your Tokens” ]

What tweaks could we make to this shortcode to get the two items of showing the events in order of date and showing only upcoming ones?


Tony

  • Support Staff

February 13, 2020 at 8:15 am

Hi there,

We filter the arguments used on the models to query he registrations/events listed on that section so you can hook i alter them if needed.

To remove expired events you can use the snippet available here:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/addons/eea-wp-user/tw_ee_filter_getTemplateObjects__query_args.php

You can add that to a custom functions plugin on your site, we have some documentation on creating one here:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

You can also use that same snippet to change the order but adding something like:

$query_args['order_by'] = array('Datetime.DTT_EVT_start' => 'ASC');

Right after Line 16 of that snippet.

If you need to modify the query further I highly recommend taking a look at our model documentation available here:

https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System

Viewing 1 reply thread

The support post ‘How can I hide old events and sort by date the events a user has registered for?’ 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