From ec5047b7496834ad1a12afe7846b49b7cd94d0c2 Mon Sep 17 00:00:00 2001 From: Boone B Gorges Date: Mon, 16 Dec 2024 10:52:04 -0600 Subject: [PATCH] Change definiton of 'is_open' filter on group directory. Changed previously on group profiles in #3391. See #3470. --- .../openlab/buddypress/groups/groups-loop.php | 14 +++--- wp-content/themes/openlab/lib/group-funcs.php | 44 +++++++++++++++++++ 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/wp-content/themes/openlab/buddypress/groups/groups-loop.php b/wp-content/themes/openlab/buddypress/groups/groups-loop.php index d0c5a8af41..e0806079fb 100644 --- a/wp-content/themes/openlab/buddypress/groups/groups-loop.php +++ b/wp-content/themes/openlab/buddypress/groups/groups-loop.php @@ -99,13 +99,8 @@ $is_open = openlab_get_current_filter( 'is_open' ); if ( $is_open ) { - $meta_query['blog_public'] = array( - 'key' => 'blog_public', - 'value' => [ '1', '0' ], - 'operator' => 'IN', - ); - - $group_args['status'] = 'public'; + add_filter( 'bp_groups_get_paged_groups_sql', 'openlab_is_open_group_query_callback', 10, 3 ); + add_filter( 'bp_groups_get_total_groups_sql', 'openlab_is_open_group_query_callback', 10, 3 ); } $active_status = openlab_get_current_filter( 'active-status' ); @@ -327,6 +322,11 @@ remove_filter( 'bp_groups_get_paged_groups_sql', 'openlab_filter_groups_query_for_active_status', 10 ); remove_filter( 'bp_groups_get_total_groups_sql', 'openlab_filter_groups_query_for_active_status', 10 ); } + +if ( $is_open ) { + remove_filter( 'bp_groups_get_paged_groups_sql', 'openlab_is_open_group_query_callback', 10, 3 ); + remove_filter( 'bp_groups_get_total_groups_sql', 'openlab_is_open_group_query_callback', 10, 3 ); +} ?> groups->table_name_groupmeta} gm_blog_public ON (g.id = gm_blog_public.group_id AND gm_blog_public.meta_key = 'blog_public')", + $groups_sql + ); + + return $groups_sql; +} + /** * Unhooks group join button if it's disabled for the group. */