I’m wondering what is a username for you.
WP register only a user by username (aka pseudonym), email and password. BP add a Name field in which you can add anything: username, first or lastname. In the user table, there is also display_name, wich is the combination of first and last name from a WP user profile, before BuddyPress was installed or if you allow your users to enter the dashboard, and they start to play with their profile settings. IMHO, it’s better they haven’t that access when BP is activated. 👮
When on the members directory, you (connected or not) can search a member by using his username.
If you use WP’s site search from toolbar or the search widget (same thing), it doesn’t work, as members are not post types… 👣
For now, i’m unsure what you want to fetch. Do you mean display_name ?
All search forms available in BP are contextualized, as @henrywright expected.
A BP class can be extended, a core function with a filter can be extended. You simply add your own to it.
In other cases, like for bp_core_action_search_site
function (in bp-core-classes.php)
there is an action and a filter. Wow. 💪
You can rewrite the whole function and use the action hook or only change a part of it by using the filter.
remove_action( 'bp_init', 'bp_core_action_search_site', 7 );
function my_custom_core_action_search_site() {
bla bla bla....
}
add_action( 'bp_init', 'my_custom_core_action_search_site', 7 );
or
add_filter( 'filter_name', function_name');
Theorie here:
https://buddypress.org/support/topic/how-to-override-core-function/
But before hacking to deep, read here:
Members Loop
Maybe you could find some interesting things about include
or search_tems
options. 👀
If all this is too much for you, consider this plugin:
https://wordpress.org/plugins/buddypress-global-search/
@prabin04, @henrywright
🚧 i’m really not an expert in matter of BP search, but thank you for your consideration.