bp_found_user_query

Filters the found user SQL statements before query.

Description

apply_filters( 'bp_found_user_query', (string) $select_found_rows, (BP_User_Query) $instance ); 

If sql_calc_found_rows is the provided count_total query var then the value will be SELECT FOUND_ROWS().. Otherwise it will use a SELECT COUNT() query statement.

Parameters (2)

0. $select_found_rows (string) => "SELECT FOUND_ROWS()"
SQL statement to select FOUND_ROWS().
1. $instance (BP_User_Query)
Current BP_User_Query instance.

Usage

To run the hook, copy the example below.
  1. $select_found_rows = apply_filters( 'bp_found_user_query', $select_found_rows, $instance ); 
  2.  
  3. if ( !empty( $select_found_rows ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the bp_found_user_query callback 
  2. function filter_bp_found_user_query( $select_found_rows, $instance ) { 
  3. // make filter magic happen here... 
  4. return $select_found_rows
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'bp_found_user_query', 'filter_bp_found_user_query', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'bp_found_user_query', 'filter_bp_found_user_query', 10, 2 ); 

Defined (2)

The filter is defined in the following location(s).

/bp-core/classes/class-bp-user-query.php  
  1. $this->total_users = $wpdb->get_var( apply_filters( 'bp_found_user_query', "SELECT FOUND_ROWS()", $this ) ); 
  1. $this->total_users = $wpdb->get_var( apply_filters( 'bp_found_user_query', "{$count_select} {$this->uid_clauses['where']}", $this ) );