Support

Home Forums Event Espresso Premium Filter Function breaks EE4 after upgrading plugin

Filter Function breaks EE4 after upgrading plugin

Posted: April 22, 2024 at 7:50 am


Kim Cooper

April 22, 2024 at 7:50 am

We were using some filters from the GIT repository and have determined the below functions break EE4. After adding this to a separate plugin, EE4 no longer shows our events on the website.
function de_ee_tweak_event_list_exclude_ticket_expired_events_where( $SQL, WP_Query $wp_query ) {
if ( isset( $wp_query->query_vars['post_type'] ) && ( $wp_query->query_vars['post_type'] == 'espresso_events' || ( is_array( $wp_query->query_vars['post_type'] ) && in_array( 'espresso_events', $wp_query->query_vars['post_type'] ) ) ) && ! $wp_query->is_singular ) {
$SQL .= ' AND Ticket.TKT_end_date > "' . current_time( 'mysql', true ) . '" AND Ticket.TKT_deleted=0';
}
return $SQL;
}
add_filter( 'posts_where', 'de_ee_tweak_event_list_exclude_ticket_expired_events_where', 15, 2 );
function de_ee_tweak_event_list_exclude_ticket_expired_events_join( $SQL, $wp_query ) {
if ( isset( $wp_query->query_vars['post_type'] ) && ( $wp_query->query_vars['post_type'] == 'espresso_events' || ( is_array( $wp_query->query_vars['post_type'] ) && in_array( 'espresso_events', $wp_query->query_vars['post_type'] ) ) ) && ! $wp_query->is_singular ) {
if ( ! $wp_query->is_espresso_event_archive && ! $wp_query->is_espresso_event_taxonomy ) {
$SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . EEM_Event::instance()->table() . '.ID = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name() . ' ) ';
}
$SQL .= ' INNER JOIN ' . EEM_Datetime_Ticket::instance()->table() . ' AS Datetime_Ticket ON ( Datetime_Ticket.DTT_ID=' . EEM_Datetime::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name() . ' ) INNER JOIN ' . EEM_Ticket::instance()->table() . ' AS Ticket ON ( Datetime_Ticket.TKT_ID=Ticket.' . EEM_Ticket::instance()->primary_key_name() . ' ) ';
}
return $SQL;
}
add_filter( 'posts_join', 'de_ee_tweak_event_list_exclude_ticket_expired_events_join', 3, 2 );

We do have another function from the GIT library (showing number of tickets remaining) and it works fine.
These were working fine until we upgraded to the lastest version of the plugin.


Rio

  • Support Staff

April 22, 2024 at 9:35 pm

This reply has been marked as private.


Tony

  • Support Staff

April 25, 2024 at 4:54 pm

Hi there,

Rather than rolling back EE core, you can update the above snippet to this one:

https://gist.github.com/Pebblo/f6999040cf2df3965c1b75ac99f9c20b

That should work with the later versions of Event Espresso.

You must be logged in to reply to this support post. Sign In or Register for an Account

Event Espresso