BuddyDev

BuddyPress User searching by User Roles

Yesterday, One of our members A. Zidi,  asked me how to filter user searches by roles when using BP Profile Search plugin by Andrea. A few months ago, Andrea helped me in integrating one of our plugins to BP Profile Search( Thank you Andrea ).

In order to allow searching by Roles, I just followed along and created a new pseudo role field type to integrate. The goal of this field type is to integrate with the BP Profile Search plugin and allow search scoping by user roles. I call it pseudo role field as roles can not contain data from user and this field is not visible to the user on their profile.

If you are using BP Profile Search plugin,  you can use the BuddyPress Pseudo Role Field plugin to allow user filtering by roles.

Screenshots:-

 

Usage:-

To Use this plugin, first of all make sure you have BP Profile Search plugin installed. It does not depend on that plugin but will be meaningless to use without that.

Step1:- Create an xprofile field by Visiting Users->Profile Field. In the filed type drop down, select “Pseudo Role” as shown below.

Xprofile Dropdown field type

Xprofile Dropdown field type

 

Step2:- Edit your search form by visiting Users->Profile Search. On the Edit search form screen, select the role field as shown below( I named it role, you can name it anything ).

BP Profile search Form

BP Profile search Form

That’s all. Now save the form and visit your search form. You will see the role dropdown in the searchform. Your users can start searching by the role.

Advance search form

Advance search form

 

Customization:-

There are times when you may not want to allow searching by all roles. No problem, we have got you covered.  This plugin provides a filter to exclude roles from dordown. Here is an example showing how to exclude Subscribers from the list.

You can exclude other roles too. Just add them to the $excluded_role array.

Download & Installation:-

https://buddydev.com/plugins/bp-pseudo-role-field/

Since you have reached here,  I will tell you a secret. We are releasing the most flexible, highly customizable, feature rich BuddyPress premium theme within next few days(3-5 days). If you are looking to build the next most awesome BuddyPress based site, I will advise waiting for a few days before purchasing any theme( For your own good ). We guarantee that you haven’t seen anything even nearly as cleanly coded as that.

8 Responses to BuddyPress User searching by User Roles

  • Hey Guys!

    Is it right that this plug-in does not work with the new BuddyPress 2.5.10?

    Greetings

    Nico

    • Hi Nico,
      Thank you for the comment. I don’t see any reason why it won’t work with 2.5.1.

      Please use it and if you have any issues, Please open a topic on our forums, we will be there to assist.

      Thank you
      Brajesh

      • It’s not working with Buddypress 2.7.4

        please Check

        • Hi Aejaz,
          Please upgrade to 1.0.3. Due to a change in BP profile search plugin it stopped working. I have updated the plugin to make it compatible again.

  • i just want to show only one role in search how to do that, as i don’t know meta of all roles to write in exclude roles

    • In that case you can use like this

      Please change the key,value of the role names appropriately.

  • Hi Brajesh
    I tried this plugin.. but it is not working now.. does it need to be updated ?
    pls advise

    • Hi Mahaprabhu,
      This plugin is not updated to work with BP profile Search 4.5+ I will add it to our custom xprofile field types plugin and update by next Monday.

      Thank you
      Brajesh

Subscribe