Skip to:
Content

BuddyPress.org

Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#5456 closed enhancement (fixed)

Filter bp_has_groups query args

Reported by: offereins's profile Offereins Owned by: boonebgorges's profile boonebgorges
Milestone: 2.0 Priority: normal
Severity: normal Version: 1.9.2
Component: Groups Keywords:
Cc:

Description

Currently there is no convenient way to prevent bp_has_groups() from using $_GET['s'] for querying groups matching search terms. Bypassing this behavior would be great for use cases where the groups query is not the primary page query and thus should ignore the search parameters, possibly among others.

Suggested is to add a filter before sending the query args to BP_Groups_Template().

See http://buddypress.org/support/topic/use-bp_has_groups-without-search-parameter/.

Change History (3)

#1 @boonebgorges
11 years ago

  • Milestone changed from Awaiting Review to 2.0

Adding a filter to the arguments is a pretty general solution to this specific issue. The problem is that bp_has_groups() is a bully about the 'search_terms' argument: it overrides values passed to the function, in favor of those found in the URL parameters. Let's correct this issue before adding general filters.

So, in brief, you can ensure that search params won't apply like this:

if ( bp_has_groups( array( 'search_terms' => false, ) ) ) : // ...

#2 @boonebgorges
11 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 8116:

Auto-fetch URL search parameters in bp_has_groups() before parsing $args array

Our previous method, of getting the search term out of $_REQUEST, had the
effect of overriding any search terms that were passed to the bp_has_groups()
function. Among other problems, this made it impossible to get an unfiltered
group list when looking at a page that was using an 's' parameter for something
else.

Fixes #5456

#3 @boonebgorges
10 years ago

In 8447:

Set default search terms before function params are parsed in bp_has_blogs()

By getting the default value of the search_terms parameter from $_REQUEST
before parameters are parsed, we ensure that 'search_terms' is passed to the
bp_parse_args() filter in the same way as the rest of the function params.

See #5456 and r8116 for a similar change in bp_has_groups()

See #5660

Note: See TracTickets for help on using tickets.