Skip to:
Content

BuddyPress.org

Ticket #2593: filter_get_users_sql.patch

File filter_get_users_sql.patch, 1.1 KB (added by boonebgorges, 14 years ago)
  • bp-core-classes.php

     
    188188
    189189                if ( $limit && $page )
    190190                        $sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     191               
     192                $paged_users_sql = apply_filters( 'bp_core_get_paged_users_sql', join( ' ', (array)$sql ) );
    191193
    192194                /* Get paginated results */
    193                 $paged_users = $wpdb->get_results( join( ' ', (array)$sql ) );
     195                $paged_users = $wpdb->get_results( $paged_users_sql );
    194196
    195197                /* Re-jig the SQL so we can get the total user count */
    196198                unset( $sql['select_main'] );
     
    209211
    210212                array_unshift( $sql, "SELECT COUNT(DISTINCT u.ID)" );
    211213
     214                $total_users_sql = apply_filters( 'bp_core_get_total_users_sql', join( ' ', (array)$sql ) );
     215
    212216                /* Get total user results */
    213                 $total_users = $wpdb->get_var( join( ' ', (array)$sql ) );
     217                $total_users = $wpdb->get_var( $total_users_sql );
    214218
    215219                /***
    216220                 * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.