bp_core_users_by_letter_sql

Filters the SQL used to query for users by first letter.

Description

Parameters (1)

0. $wpdb_prepare_select_distinct_u_id_as_id_u_user_registered_u_user_nicename_u_user_login_u_user_email_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_pag_sql_bp_xprofile_fullname_field_name_letter_like (string)
The wpdb prepare select distinct u id as id u user registered u user nicename u user login u user email 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 pag sql bp xprofile fullname field name letter like.

Usage

To run the hook, copy the example below.
  1. $wpdb_prepare_select_distinct_u_id_as_id_u_user_registered_u_user_nicename_u_user_login_u_user_email_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_pag_sql_bp_xprofile_fullname_field_name_letter_like = apply_filters( 'bp_core_users_by_letter_sql', $wpdb_prepare_select_distinct_u_id_as_id_u_user_registered_u_user_nicename_u_user_login_u_user_email_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_pag_sql_bp_xprofile_fullname_field_name_letter_like ); 
  2.  
  3. if ( !empty( $wpdb_prepare_select_distinct_u_id_as_id_u_user_registered_u_user_nicename_u_user_login_u_user_email_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_pag_sql_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_sql callback 
  2. function filter_bp_core_users_by_letter_sql( $wpdb_prepare_select_distinct_u_id_as_id_u_user_registered_u_user_nicename_u_user_login_u_user_email_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_pag_sql_bp_xprofile_fullname_field_name_letter_like ) { 
  3. // make filter magic happen here... 
  4. return $wpdb_prepare_select_distinct_u_id_as_id_u_user_registered_u_user_nicename_u_user_login_u_user_email_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_pag_sql_bp_xprofile_fullname_field_name_letter_like
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'bp_core_users_by_letter_sql', 'filter_bp_core_users_by_letter_sql', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'bp_core_users_by_letter_sql', 'filter_bp_core_users_by_letter_sql', 10, 1 ); 

Defined (1)

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

/bp-core/classes/class-bp-core-user.php  
  1. $paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email 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{$pag_sql}", bp_xprofile_fullname_field_name(), $letter_like ) );