Index: bp-core-classes.php
===================================================================
--- bp-core-classes.php	(revision 3204)
+++ bp-core-classes.php	(working copy)
@@ -188,9 +188,11 @@
 
 		if ( $limit && $page )
 			$sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
+		
+		$paged_users_sql = apply_filters( 'bp_core_get_paged_users_sql', join( ' ', (array)$sql ), $sql );
 
 		/* Get paginated results */
-		$paged_users = $wpdb->get_results( join( ' ', (array)$sql ) );
+		$paged_users = $wpdb->get_results( $paged_users_sql );
 
 		/* Re-jig the SQL so we can get the total user count */
 		unset( $sql['select_main'] );
@@ -209,8 +211,10 @@
 
 		array_unshift( $sql, "SELECT COUNT(DISTINCT u.ID)" );
 
+		$total_users_sql = apply_filters( 'bp_core_get_total_users_sql', join( ' ', (array)$sql ), $sql );
+
 		/* Get total user results */
-		$total_users = $wpdb->get_var( join( ' ', (array)$sql ) );
+		$total_users = $wpdb->get_var( $total_users_sql );
 
 		/***
 		 * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
