Skip to:
Content

BuddyPress.org

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
Cc:

Description

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:
http://173.203.96.126/buddypress-groupcount-hooks.diff
https://github.com/OccupyWallStreet/nycga2/commit/08b83669375c312926e67848e67ec0224aa51e4f

best,

dan

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 https://buddypress.trac.wordpress.org/browser/tags/1.5.4/bp-groups/bp-groups-template.php#L1642 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.