Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search members based on their usernames in members page search bar


  • Binayk
    Participant

    @binayk

    Currently the members are searched based on first letter or the first name, but if we try to search based on their user names it shows empty results even if the user is present, so will it be possible to search members/friends based on their usernames.Also referred to previous posts related to same topic but only option solution that was mentioned is changing core file “buddypress/bp-core/bp-core-classes.php” which is inappropriate (WordPress version 4.3, Buddypress version 2.3.3)

Viewing 7 replies - 1 through 7 (of 7 total)

  • Lionel
    Participant

    @prabin04

    @danbp can you look into this?


    Henry Wright
    Moderator

    @henrywright

    I’m not sure that the standard member search looks for usernames. @danbp can you shed any light on that?

    You may need to use the BP Profile Search plugin.


    Lionel
    Participant

    @prabin04

    hi @henrywright thankx for the reply.
    In the member profile, we can search by both username or first name, but searched user have to be on friend-list of the member. Can we search users who are not in the friendlist? any trick for search form or widget plugin?


    Henry Wright
    Moderator

    @henrywright

    Can we search users who are not in the friendlist?

    You can in the site search at example.com/members but elsewhere I’m not so sure. If there was a search box on a member’s profile page then I’d expect that to return that member’s friends only. It wouldn’t make sense to return non-friends. But that’s just my personal opinion.


    danbp
    Moderator

    @danbp

    Search by username is not possible yet with the mentionned plugin.
    https://wordpress.org/support/topic/search-by-username

    If you’re comfortable with coding, see this gist.

    Site search source code is in bp-core-functions.php:2236


    danbp
    Moderator

    @danbp

    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.


    Lionel
    Participant

    @prabin04

    @danbp, @henrywright thanks for the feedback. 😀 I may have to need your other further helps regarding BuddyPress issues and modifications.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Search members based on their usernames in members page search bar’ is closed to new replies.
Skip to toolbar