Created
May 11, 2021 20:19
-
-
Save Pebblo/334ba1f465a367fe9fd14749b9c8dede to your computer and use it in GitHub Desktop.
Example of how to filter the query used to pull events/registrations into the My Events section.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Please do not add the opening PHP tag if you already have one. | |
// The blow includes various options to filter the events/registrations on the My events section. | |
// By default the snippet changes the ordering to be by Event Start date ASC but just uncomment | |
// any additional query_vars you may need, for example remove // from the beginning of line 16 | |
// to also only show Upcoming/Active events. | |
add_filter( | |
'FHEE__Espresso_My_Events__getTemplateObjects__query_args', | |
'tw_ee_filter_getTemplateObjects__query_args', | |
10, | |
3 | |
); | |
function tw_ee_filter_getTemplateObjects__query_args( $query_args, $template_args, $att_id) { | |
if ($template_args['object_type'] === 'Event') { | |
// Only show upcoming/active events | |
//$query_args[0]['Datetime.DTT_EVT_end'] = array( '>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')); | |
// Only show Approved registrations | |
//$query_args[0]['Registration.STS_ID'] = EEM_Registration::status_id_approved; | |
// Order by Event Start date ASC | |
$query_args['order_by'] = array('Datetime.DTT_EVT_start' => 'ASC'); | |
} | |
if ($template_args['object_type'] === 'Registration') { | |
//These apply to the simple_list_table template | |
// Only show upcoming/active events | |
//$query_args[0]['Event.Datetime.DTT_EVT_end'] = array( '>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')); | |
$query_args['order_by'] = array('Event.Datetime.DTT_EVT_start' => 'ASC'); | |
} | |
return $query_args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment