Skip to:
Content

BuddyPress.org

Ticket #4064: buddypress-groupcount-hooks.diff

File buddypress-groupcount-hooks.diff, 2.2 KB (added by drassi, 13 years ago)
  • wp-content/plugins/buddypress/bp-groups/bp-groups-classes.php

    diff --git a/wp-content/plugins/buddypress/bp-groups/bp-groups-classes.php b/wp-content/plugins/buddypress/bp-groups/bp-groups-classes.php
    index f446702..1c9de0e 100644
    a b Class BP_Groups_Group { 
    578578                if ( !is_super_admin() )
    579579                        $hidden_sql = "WHERE status != 'hidden'";
    580580
    581                 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql}" ) );
     581                $group_count_sql = "SELECT COUNT(id) FROM {$bp->groups->table_name} g {$hidden_sql}";
     582                $group_count_sql = apply_filters( 'bp_group_get_total_group_count', $group_count_sql );
     583                return $wpdb->get_var( $wpdb->prepare( $group_count_sql ) );
    582584        }
    583585
    584586        function get_global_forum_topic_count( $type ) {
    Class BP_Groups_Member { 
    939941                        $user_id = $bp->displayed_user->id;
    940942
    941943                if ( $user_id != $bp->loggedin_user->id && !is_super_admin() ) {
    942                         return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $user_id ) );
     944                        $group_count_sql = "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0";
    943945                } else {
    944                         return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $user_id ) );
     946                        $group_count_sql = "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0";
    945947                }
     948                $group_count_sql = apply_filters( 'bp_group_member_get_total_group_count', $group_count_sql );
     949                return $wpdb->get_var( $wpdb->prepare( $group_count_sql, $user_id ) );
    946950        }
    947951
    948952        function get_invites( $user_id, $limit = false, $page = false, $exclude = false ) {