bp_core_users_by_letter_count_sql

Filters the SQL used to query for total user count by first letter.

Description

Parameters (1)

0. $wpdb_prepare_select_count_distinct_u_id_from_wpdb_users_u_left_join_bp_profile_table_name_data_pd_on_u_id_pd_user_id_left_join_bp_profile_table_name_fields_pf_on_pd_field_id_pf_id_where_status_sql_and_pf_name_s_exclude_sql_and_pd_value_like_s_order_by_pd_value_asc_bp_xprofile_fullname_field_name_letter_like (number)
The wpdb prepare select count distinct u id from wpdb users u left join bp profile table name data pd on u id pd user id left join bp profile table name fields pf on pd field id pf id where status sql and pf name s exclude sql and pd value like s order by pd value asc bp xprofile fullname field name letter like.

Usage

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

Defined (1)

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

/bp-core/classes/class-bp-core-user.php  
  1. $total_users_sql = apply_filters( 'bp_core_users_by_letter_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT u.ID) FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE %s ORDER BY pd.value ASC", bp_xprofile_fullname_field_name(), $letter_like ) );