BP Profile Search
[Updated April 20, 2012]
When I had a chance to look into BuddyPress, the ‘social networking in a box’ for WordPress, I noticed that a plugin to search, or filter, the members directory was still missing, and that prompted me to release BP Profile Search.
In this page you can find the updated documentation for BP Profile Search 3.0.
Features
BP Profile Search adds a configurable search form to your BuddyPress site, so visitors can find site members searching their extended profiles.
You can insert the search form in a post or page, or in a sidebar or widget area, or anywhere in your theme, e.g. in your Members Directory template file.
In all three cases when visitors click ‘Search’, they are served your Members Directory page showing their search results.
Configuration
After the standard manual or automatic plugin installation procedure, you can access the plugin admin page BuddyPress -> Profile Search, where you have the following options:
* Specify the HTML text for the form header and welcome message.
* Enable the toggle form feature.
* Select the profile fields to include in the search form (currently the datebox profile fields are not supported).
* If your extended profiles include a birth date field, enable the age range search, so your visitors can specify the minimum and maximum age for their search.
* Select the members list to filter, if your Members Directory page contains more than one.
* Select the search mode for text fields, between:
– partial match, where a search for John matches John, Johnson, or Long John Silver;
– exact match, where a search for John matches John only.
In both search modes the wildcard characters % (percent sign), matching zero or more characters, and _ (underscore), matching exactly one character, are available to your visitors to better specify their search.
Displaying the search form
There are three different ways to integrate your BP Profile Search form in your BuddyPress site. You can insert the form:
a) in a post or page, using the shortcode [bp_profile_search_form]
b) in a sidebar or widget area, using the BP Profile Search widget
c) in your template files, e.g. in your Members Directory page, using the code
<?php do_action (‘bp_profile_search_form’); ?>
Shortcodes and widgets are standard WordPress features, so I won’t explain their usage here. Adding the search form in your template files is also very simple, as shown in the following example.
If you wish to add the search form to your Members Directory page, and you are using the BuddyPress default theme, open index.php in the buddypress/bp-themes/bp-default/members folder, locate the line:
</div><!-- #members-dir-search -->
and, right after that, insert the BP Profile Search form:
<?php do_action ('bp_profile_search_form'); ?>
If you are not using the BuddyPress default theme, the procedure might be different.
Troubleshooting
If your searches always return the full members list, try changing the Filtered Members List value in BuddyPress -> Profile Search, Advanced Options tab.
Conclusions
I hope you find this plugin useful and help me improve it, with your suggestions, bug reports, and patches. BP Profile Search is available for download in the WordPress Plugin Directory and in the BuddyPress Plugin Directory.
Hello Steve,
I’m not able to reproduce that error. If you wish I debug this issue on your test site, please send me your WP admin and FTP login data (to andrea@blogsweek.com).
Hi Andrea,
I’m new to this plugin and was wondering if it is possible to do a drill down search. If I select a category, then there are sub-categories based on that specific main category to choose from. Then be able to select a location.
Ex.: Category – Artist; Sub-category – Sketching; Location – 30324 (could be city, state)
Is that feasible with this plug-in?
Hi Tim,
That’s not possible with the current version, but it’s a good idea for a future version. Thank you for your feedback!
@andrea
Hi Steve,
I found a strange workaround for that strange problem, just rename the ps-main.php plugin file. Names like main.php or bps-main.php are ok.
I don’t know why, but it works. I’ll let you know if I discover something more.
Hello, I have tried to add this plugin to my latest site but it seems that it is not compatible as is no longer on that page. Is it due to the WordPress update and do you know when you will have a fix.
Andy
Hello Andy,
If you have a multisite installation you may need this patch:
http://www.blogsweek.com/patch-for-wp-3-1-and-bp-1-2-8/
To my knowledge, the BuddyPress default theme has not changed in the ‘members’ area, and I’m not aware of any other issues.
Hi andrea, thanks I got it working now.
Hey guys,
Thanks so much for your great work!
Any way you can incorporate this in a normal page?
Hi Geordie,
You can do that if you write a custom page template. That page template should contain:
1. The form calling code, that is:
<?php do_action (‘bp_profile_search_form’); ?>
2. Some code to list all your site members. You could copy that code from the members directory page in your theme.
Now create a new blank page using the page template you just wrote, and enjoy your new Member’s Profile Search Page!
Looking to sort/search users by wp role. Is there any way I can add this piece in? Maybe a drop to filter the list? Thanks.
Hi Leland,
That feature is not available in the current plugin version, but it’s a good suggestion for a future release.
I have uploaded the BP Profile Search version 2.5 into my BP Theme. And I am trying to instal the profile search form following line 14: But it is not to be found in the index.php of our WordPress Blog/Buddypress. What to do next?
Hi Steve,
Please let me know which theme you are using, so I can tell you where to add the plugin call.
Hello,
I have your search working on a separate page.
But I need pagination. on the search results.
I can get all the userids from:
bps-functions – $params['include'] = $wpdb->escape (implode (‘,’, $userids));
And plan to stuff them in a GET or POST, and then query based on a subset of the userids.
But where are you creating the query that returns search results ?
So I can bypass it and use a custom query?
Sorry, new to BP.
Ok – you’re using bp_core_get_users to get results, yes?
Any hints on how to customize the data returned for each user?
(ex. remove the Friend, Follow buttons)
Pagination ?
The per-page field is fine on the first page, but the pagination links are unaware of the search terms.
also – thanks for providing this code. Seems like a natural for inclusion in next big BP release.
Hi and thanks for the plugin, it works perfect for me. However (well, is hard to satisfy me
100%) I’d like to know if/how can I restrict a search so it will show only certain values (between range) of a specific field. More exactly, I have a ‘price’ field and I’d like the search to display only prices between 200 and 5000, for example. Similar to the ‘agerange’ option.
Thanks again!
Customized the data returned for each user by using a custom members-loop.
Still trying to create custom pagination.
Hello Sam,
The whole set of search results is stored in the $userids array in ‘bps-functions.php’, function ‘bps_search ‘. That function filters ‘bp_core_get_users’, forcing it to return the search results instead of the standard members list. Probably you can start from here to build a pagination; I tried to build one using cookies, but without success so far.
@Watt
Hello Watt,
That feature is not available yet, but it’s a good suggestion for a future release. Thanks for your feedback!
Got pagination working.
I pass the full set of ids to each page in a GET, but I limit results to 200, 20 per page, so it’s not too bad.
How to add a GET string to a WP url:
http://codex.wordpress.org/Function_Reference/add_query_arg
Generate and format the links:
http://codex.wordpress.org/Function_Reference/paginate_links
Hello Sam,
That’s good, congratulations! If you send me your patch, I might add it to the next BP Profile Search release.
Hi,
This plugin has been exactly what I needed for my site, however I am having trouble converting this into a “search” feature rather than a “filter” feature. I have been able to have it filter the correct matches out of an already existing / displayed list of members, but I can’t it to start with nothing and then have it display the desired search terms. Has anybody had any success doing this?
I have tried fiddling around with the code in the members page and with the code in /members/members-loop.php in the hopes of getting the members section to display nothing until a search is requested, but with no success. Does anybody have any advice on how to accomplish this task correctly? Any help would be appreciated.
Thanks!
Adam
I’ve noticed that if I remove this line
from /members/members-loop.php, the full member directory goes away, but then nothing is displayed when I put my search terms into this plug-in. Is there any way to modify this line so that it will not display anything until I enter my terms in?
Hello Adam,
At this moment there is no way to build a ‘search’ page instead of a ‘filtering’ feature. I have that in my to-do list, so you might find it in a future BP Profile Search release.
I’m sorry to hear that. Thank you for your response though!
I have a different theme form the default BP theme. The theme I’m using is Simple WP Community Theme 1.6. Where do I add the extra code in.
Hi Remi,
I’ll take a look at your theme and I’ll post the instructions here in this weekend.
I have WP 3.1.1 and BuddyPress 1.2.8. I installed this plug in and added the after line 14. I’m still using the default BP theme. The Profile Search From shows in the Members Tab, but all I see is the Search Button and ‘Clear Form’…there are no fields. Thanks in advance.
Hi Scott,
You can add selected fields to your search from the plugin admin page.
I have Simple WP Community Theme 1.6. Where do I add the extra code in? please help me and please be a bit specific. thankyou
@Remi , @guru
The instructions for your theme are the same standard instructions:
Open index.php in the wp-content/themes/simple-wp-community-theme/members folder, locate this line (around line 14):
</div><!– #members-dir-search –>
and, right after that, insert the BP Profile Search form:
<?php do_action ('bp_profile_search_form'); ?>Done!
Hi Andrea I am very interested in knowing where specifically to add this code, I activated the plugin and got the code, I have the My Buddypress Theme as my theme. I did notice that out of the six buddypress theme I have installed only two of them give you the members folder where you can go to line 14 and add that code which are BP Collums and simple-wp-community-theme, My-buddypress is the only theme that I want to use. can you walk me step by steps on how to add the code. your assistant is appreciated.
Hi Auxson,
My BuddyPress is a child theme of the BP default theme, so you can add the BP Profile Search call to the default theme and that will show in your child theme too.
Hi Andrea,
Many thanks for this plugin, which features are exactly what I’m looking for.
Unfortunately, I can’t get it filter the members : it always shows all members. (note: “Regular WP seach” runs OK).
I have tried to change the “Member list ID” (I have 4, don’t ask me why … Maybe the issue is here?) and nothing changes.
Could please you help me in solving this ?
(WP 3.1 + BP 1.2.8 + BPPS 2.5 + customised ATA theme).
@Manu-PB
Did you try to deactivate all your plugins? If you can’t solve this issue you could send me your login data so I can have a look at your installation.
Hi Andrea, I downloaded your plugin, uploaded it via ftp (also tried via the plugins install page), activated it, included the php line in my template, but there is no “Profile Search” under Buddypress. Have tried numerous times to delete the plugin and instal/activate it again. Any ideas? using the latest version of WordPress and BuddyPress. Thanks!
@Andrew
Hi Andrea, it seems to be a known problem with WP 3.1 and multisite. I was able to get your menu appearing by following the tutorial here – http://buddydev.com/buddypress/wordpress-multisite-3-1-and-fixing-the-problems-with-buddypress-dependent-plugins/
Hi Andrew,
Thank you for your feedback. I noticed that with WP 3.1 + BP 1.2.8 + BPPS 2.5 the ‘Network Activate’ doesn’t work, but the simple ‘Activate’ does. Could you confirm that?
Anyway I’m going to fix the ‘Network Activate’ too. Thanks again!
I have a 8000+ Buddypress site and when I try to do a simple search based on one custom field I get this error:
Fatal error: Maximum execution time of 30 seconds exceeded in /home/naughtybox/hotwifelife.com/wp-content/plugins/buddypress/bp-core/bp-core-classes.php on line 352
Any idea how I can fix this?
@mistafro
Probably the plugin code is not optimized for a large user base. I’ll think about it and I’ll try to send you a test version next week.
@andrea
That would be awesome, I really need the features of this plugin but it’s choking on that amount of members. Thanks
@andrea
Don’t mean to bother you but any luck with a test version for the large member sites?
@andrea
Great looking tool – but I am at a loss on how to insert the code in the Fishbook theme. I have searched everywhere for the a file or similar and I still cannot locate it. Could you offer some guidance please?
OK Andrea – I have found the files – I did not go through the Plugins/Buddypress and then follow the structure – sorry attention to detail needed on my behalf.
One thing – how would I go about match the fonts to the font I use elsewhere on my site. – where could I change this? Sorry CSS not my strong point
@Scotty
Hi Scotty,
I spent some time looking at your Members page, but I’ve not been able to fix the fonts. BP Profile Search should automatically use the active theme fonts, but for some reason it doesn’t. Sorry!
@andrea
Thanks @andrea
I saw you register so I guessed you were looking – thanks anyway, I appreciate your efforts.
Do you think this is my issues or an issue with the plug in?
@Scotty
I think it’s an incompatibility between the plugin and the theme CSS. To overcome it, you can add some CSS rules to your theme’s style.css file, and change the fonts according to your preference.
@mistafro
I hope I’ll find some time during this week end. Thanks for your patience!
any update on the progress on this? just want to make sure I didn’t miss something.
@andrea
any update?