Or maybe the opposite, just dont allow Subscribers in the result.
I was also thinking that i could skip the use of define( 'BP_MESSAGES_AUTOCOMPLETE_ALL', true );
and since i just want to have in the autocomplete contributors+admins
it could be a function that makes all of those users friends with out the need of bp friends component?
So i managed to find the appropriate code in case someone also needs it:
define( 'BP_MESSAGES_AUTOCOMPLETE_ALL', true );
/**
* Filter and remove subscribers and user's own mail from all BuddyPress auto complete box.
*
* @param array $args BP_User_Query args.
*
* @return array
*/
function buddydev_filter_buddypress_auto_complete_ids( $args ) {
$user_ids = isset( $args['exclude'] ) ? $args['exclude'] : array();
if ( $user_ids && ! is_array( $user_ids ) ) {
$user_ids = wp_parse_id_list( $user_ids );
}
$excluded = get_users( array( 'role' => 'subscriber', 'fields' => 'ID' ) );
if ( is_user_logged_in() ) {
array_push( $excluded, get_current_user_id() );
}
$args['exclude'] = array_merge( $excluded, $user_ids );
return $args;
}
add_filter( 'bp_members_suggestions_query_args', 'buddydev_filter_buddypress_auto_complete_ids' );
with this i can have excluded from autocomplete all subscribes by hooking to bp_members_suggestions_query_args