Skip to:

Opened 12 years ago

Closed 12 years ago

#4064 closed enhancement (no action required)

Adding hooks into group count functions in bp-groups-classes (incl. patch)

Reported by: drassi's profile drassi Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Core Keywords: has-patch


I helped write a plugin that allows us to filter BP groups and was successfully able to use the bp_groups_get_(total/paged)_groups_sql hooks to modify the list of groups returned on the group directory.

However, I was unable to modify the queries that returned the counts for "All Groups" and "My Groups" because there were no hooks in the bp-groups-classes.php get_total_group_count and total_group_count functions. I wrote these small hooks in, and am submitting them to see if it'd be possible to get them included in BP core at some point.

Here's the link to my raw diff and the github commit on our repo:



Attachments (1)

buddypress-groupcount-hooks.diff (2.2 KB) - added by drassi 12 years ago.

Download all attachments as: .zip

Change History (3)

#1 @fanquake
12 years ago

  • Keywords has-patch added

#2 @boonebgorges
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

We're happy to add filters when needed. When possible, though, we prefer to avoid adding filters directly to SQL queries.

In your case, I believe there are already filtered template functions that provide the values you're looking for. For a total site group count, use bp_get_total_group_count(). For a count of a user's groups, use bp_get_total_group_count_for_user(). See These functions get their values from the query methods you have patched, and they already have filters in place.

Going to close this ticket as invalid in the meantime. If there's a reason why those template functions won't work, feel free to reopen the ticket with further explanation. Thanks!

Note: See TracTickets for help on using tickets.