Skip to:

Use bp_has_groups() without search parameter

  • Using WP 3.8.1 + BP 1.9.1, when developing with BuddyPress I’m faced with the following issue.

    On an WP admin page that serves a WP_List_Table with a common search box (like posts.php or users.php) any default bp_has_groups() query call returns just that what you’d expect: all available groups. But when the search box is used to filter the elements within the list table and an 's' query parameter appears in $_GET and $_REQUEST, the groups query reads the search terms for the groups query, thus returning only groups that match the 's' query parameter. This happens on line 340 of bp-groups/bp-groups-template.php. Though understandable, this is not the desired result, since the groups query is absolutely separate from anything associated with the list table query elements.

    The only filter to modify the groups query from bp_has_query() untill the actual SQL execution is bp_groups_get_paged_groups_sql in BP_Groups_Group::get(), but it cannot receive any custom arguments from bp_has_query if I would want to bypass the search sql statement like that.

    One solution that works is to manually unset and reset the 's' query parameter before and after each bp_has_groups() call, but that’s not something I really like doing. Another similar way is to set a global flag for each time to ignore the search terms.

    Is this intended behavior?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Use bp_has_groups() without search parameter’ is closed to new replies.
Skip to toolbar