BuddyDev

Creating The sitewide global/unified search Page for your Buddypress Theme


Update:- 20th July 2010: Just checked the file with bp-default and forund the bug as mentioned in the comments, the invisible sidebar issue. I have updated the tutorial and the attached file. Now it will have no issues like invisible sidebar. There was a wrong placement of div causing issue.
As I promised a few days ago, Creating a sitewide unified/single  search page  does not require advance knowledge. It can be done via themes. Nothing extra is required. Here I will go step by step to show you how can accomplish that.

Until otherwise mentioned all the functions should go to your theme's functions.php

Step1:  Remove the drop-down for members/groups  from the search from etc.

[sourcecode language="php"]

/*remove the component select drop down, we don't want them */

add_filter("bp_search_form_type_select", "bpmag_remove_search_dropdown" );
function bpmag_remove_search_dropdown($select_html){
return "";
}

[/sourcecode]

The above code will remove the drop down for members/groups etc which you see just after the search input box.

Step2: Stop the Redirect:-

Based on the search type selected, BuddyPress redirects you to different search pages like members?s= searchterm or groups?s=searchterm.

We just want to stop BuddyPress from doing so.

[sourcecode language="php"]

remove_action( 'init', 'bp_core_action_search_site', 5 );//force buddypress to not process the search/redirect

[/sourcecode]

Now since Buddypress will not handle the search for you, so we need to handle it ourself.

Step 3: Handle The Search

[sourcecode language="php"]

add_action( 'init', 'bp_buddydev_search', 10 );// custom handler for the search

function bp_buddydev_search(){
global $bp;
if ( $bp->current_component == BP_SEARCH_SLUG )//if this is search page
bp_core_load_template( apply_filters( 'bp_core_template_search_template', 'search-single' ) );//load the single searh template, It will load the page search-single.php from your theme
}

[/sourcecode]

So, what we do here, when ever the Search page is opened we are simply loading out advance search page template.

Step 4: Create a  search-single.php in your theme

In the content area(if you are using default theme, then inside the div "padder") put the following line

[sourcecode language="php"]

<?php do_action("advance-search");?>

[/sourcecode]

Step5:  Now we need to process the result and show it

So basically, we will check for the active component and just add their search result using the add_action, let us start with members.

[sourcecode language="php"]

/* The code here comes from my theme bpmag, so please bear with the extension bpmag_*/

//show the search results for member*/
function bpmag_show_member_search(){
?>
<div>
<h2><?php _e("Members Results","buddypress");?></h2>
<?php locate_template( array( 'members/members-loop.php' ), true ) ; ?>
<?php global $members_template;
if($members_template->total_member_count>1):?>
<a href="<?php echo bp_get_root_domain().'/'.BP_MEMBERS_SLUG.'/?s='.$_REQUEST['search-terms']?>" ><?php _e(sprintf("View all %d matched Members",$members_template->total_member_count),"buddypress");?></a>
<?php endif; ?>
</div>
<?php
}

//Hook Member results to search page
add_action("advance-search","bpmag_show_member_search",10); //the priority defines where in page this result will show up(the order of member search in other searchs)

[/sourcecode]

We have not checked for active component as member is a core component and will always  be active.

In the same fashion, we will add other search results too.

[sourcecode language="php"]

function bpmag_show_groups_search(){
?>
<div>
<h2><?php _e("Group Search","bpmag");?></h2>
<?php locate_template( array('groups/groups-loop.php' ), true ) ; ?>

<a href="<?php echo bp_get_root_domain().'/'.BP_GROUPS_SLUG.'/?s='.$_REQUEST['search-terms']?>" ><?php _e("View All matched Groups","bpmag");?></a>
</div>
<?php
//endif;
}

//Hook Groups results to search page
if(bp_is_active( 'groups' ))
add_action("advance-search","bpmag_show_groups_search",10);

/**
*
* Show blog posts in search
*/
function bpmag_show_site_blog_search(){
?>
<div>

<h2><?php _e("Blog Search","bpmag");?></h2>

<?php locate_template( array( 'search-loop.php' ), true ) ; ?>
<a href="<?php echo bp_get_root_domain().'/?s='.$_REQUEST['search-terms']?>" ><?php _e("View All matched Posts","bpmag");?></a>
</div>
<?php
}

//Hook Blog Post results to search page
add_action("advance-search","bpmag_show_site_blog_search",10);

//show forums search

function bpmag_show_forums_search(){
?>
<div>
<h2><?php _e("Forums Search","bpmag");?></h2>
<?php locate_template( array( 'forums/forums-loop.php' ), true ) ;  ?>
<a href="<?php echo bp_get_root_domain().'/'.BP_FORUMS_SLUG.'/?s='.$_REQUEST['search-terms']?>" ><?php _e("View All matched forum posts","bpmag");?></a>
</div>
<?php
}

//Hook Forums results to search page
if ( bp_is_active( 'forums' ) && bp_is_active( 'groups' ) && ( function_exists( 'bp_forums_is_installed_correctly' ) && !(int) bp_get_option( 'bp-disable-forum-directory' ) ) && bp_forums_is_installed_correctly() )
add_action("advance-search","bpmag_show_forums_search",20);

//show blogs search result

function bpmag_show_blogs_search(){

?>
<div>
<h2><?php _e("Blogs Search","bpmag");?></h2>
<?php locate_template( array( 'blogs/blogs-loop.php' ), true ) ; ?>
<a href="<?php echo bp_get_root_domain().'/'.BP_BLOGS_SLUG.'/?s='.$_REQUEST['search-terms']?>" ><?php _e("View All matched Blogs","bpmag");?></a>
</div>
<?php
}

//Hook Blogs results to search page if blogs comonent is active
if(bp_is_active( 'blogs' ))
add_action("advance-search","bpmag_show_blogs_search",10);

[/sourcecode]

So, we are almost done but not yet completely.

As you see above, we are calling the component-loop.php for each of the component. The blog search(not the blogs search) has no loop file, so we will create one for the blog search too. I call it search-loop.php(just a replication of the original search-page with some of the divs stripped, find it in the attached doc below)

Just use your themes template(just like groups-loop.php)  file and create a search-loop.php

Here is what you should put in the search-loop.php (put the search-loop.php in your theme).

[sourcecode language="php"]

<?php /* this search loop shows your blog posts in the unified search
you may modify it as you want, It is a copy from my theme

*/

?>
<?php do_action( 'bp_before_blog_search' ) ?>
<?php global $wp_query;
$wp_query->is_search=true;
$search_term=$_REQUEST['search-terms'];
if(empty($search_term))
$search_term=$_REQUEST['s'];
$wp_query->query("s=".$search_term);?>
<?php if ( have_posts() ) : ?>
<?php while(have_posts()):the_post(); global $post;?>
<?php do_action( 'bp_before_blog_post' ) ?>
<div> <!– Post goes here… –>
<div>
<h3><?php the_title();?></h3>
<div>
<?php the_excerpt();?>
</div>
<div> </div>
</div>
<div>
<span><?php the_time('F j, Y') ?>  | <?php the_category(', ') ?> | <?php comments_popup_link( __( 'No Comments &#187;', 'bpmag' ), __( '1 Comment &#187;', 'bpmag' ), __( '% Comments &#187;', 'bpmag' ) ); ?></span>
<div><a href="<?php the_permalink();?>"><?php _e("Read more…","bpmag");?></a></div>
</div>

</div><!– Post ends here… –>
<?php do_action( 'bp_after_blog_post' ) ?>
<?php endwhile;?>
<?php if(!bpmag_is_advance_search()):?>
<div>
<?php if(function_exists("wp_pagenavi"))wp_pagenavi();else{ ?>
<div><?php next_posts_link( __( '&larr; Previous Entries', 'bpmag' ) ) ?></div>
<div><?php previous_posts_link( __( 'Next Entries &rarr;', 'bpmag' ) ) ?></div>
<?php }?>
</div>
<?php endif;?>
<?php else : ?>
<div>
<div>
<?php echo sprintf(__("We are sorry, but we could not find anything for the search term '%s'","bpmag"),$search_term);?>

<?php locate_template( array( 'searchform.php' ), true ) ?>
</div>
</div>

<?php endif; ?>
<?php do_action( 'bp_after_blog_search' ) ?>

[/sourcecode]

Last Step: Modify the ajax query string

And  Now, let us modify the query string, that's final step.

[sourcecode language="php"]

//modify the param using bp_ajax_querystring

add_action("advance-search","bpmag_show_search_results",1);//highest priority

/* we just need to filter the query and change search_term=The search text*/
function bpmag_show_search_results(){
//filter the ajaxquerystring
add_filter("bp_ajax_querystring","bpmag_global_search_qs",100,2);
}

//modify the query string with the search term
function bpmag_global_search_qs(){
return "search_terms=".$_REQUEST['search-terms'];
}

[/sourcecode]

Here is the search result page. Have a look

Go ahead and type something, check the result, modify your templates and do  not forget to let me know how it went with you 🙂

224 Responses to Creating The sitewide global/unified search Page for your Buddypress Theme

  • This is an extremely useful tutorial, thanks for sharing Brajesh.

  • thanks for this Brajesh! just what i needed..very useful
    one question, can it be customized to also show web results??

    like if i search brajesh, it will show members called brajesh, forum posts by brajesh etc.. as it does now and also show a tab for web results like how it would show on google if i searched brajesh..

    • hi Andrew
      You are most welcome 🙂

      Of course It can be customized. after all we are doing everything in theme file, just edit search-single.php or add the web search block following the add_action as I have done in the code.
      Hope that helps 🙂

      • can you help me with an example as to how i would do that and where to place it?

        and would also like to let members search using an email address, how can i add that?

        thanks as always Brajesh 🙂
        hate to hear that people are stealing your codes but hey, thats how u know your doing something really great 🙂

  • Hello Brajeshda, I am using WordPress MU and Buddypress. But who create a blog from by website he see in his dashboard 'Recently WordPress News' and 'Wordpress development Blog' widget in his blog dashboard. How can I change this and change to 'Bookmania News'. Thanks.

  • The sitewide unified search is not supporting well with Cosmicbuddy. you can see at my website. And one thing I want to join the premium club. I have some Debit cards but these are not supporting Paypal. what shall I do?

    • Soubhik, you will need to modify the theme file,, I already mentioned it.
      there is nothing like plug and play. If you theme is different, the layout is different and will will have to model accordingly.
      Can we please keep the membership joining out of this discussion, Please PM me, and I will see what I can do to help you.

  • And one more thing is, when one body want to register in my site it just say 'Deleted' and just keep the user in the sign up page. So the user can not sign up. Can you solve this issue?

    • Soubhik, I have a request for you, hope you don't mind. you are using the CB theme, so let us keep the discussion about the things there. Please do not mix up the discussion of different topics with irrelevant topics.
      For Now, try to disable captcha and try again. You have so many required fields that a person like me will not even dare to register.

  • WOW – this is really great. Could use right away. Thanks alot!!!

  • Ok, Brajeshda. I will send you a PM and one thing I have tried disabling the captcha but it gives the same. And I saw in your site it also giving a thing 'DELETED' above the sign up page.

    • Soubhik,
      Thanks for the point. Please get a screenshot and point me to that(please use cosmc buddy post for that, I just want to keep the things organized).

  • Thanks a lot for this tutorial!
    This search makes much more sense.

    • thanks svenl77
      I am glad you liked it 🙂

      • Hi Brajesh Singh,

        The search script is not update friendly,
        If you disable buddypress the site crashes.

        I added if(defined( 'BP_VERSION' )) to my copy, to fix this bug.


        //Hook Groups results to search page
        if(defined( 'BP_VERSION' )){
        if(bp_is_active( 'groups' ))
        add_action("advance-search","bpmag_show_groups_search",10);
        }

        //Hook Forums results to search page
        if(defined( 'BP_VERSION' )){
        if ( bp_is_active( 'forums' ) && bp_is_active( 'groups' ) && ( function_exists( 'bp_forums_is_installed_correctly' ) && !(int) bp_get_option( 'bp-disable-forum-directory' ) ) && bp_forums_is_installed_correctly() )
        add_action("advance-search","bpmag_show_forums_search",20);
        }

        //Hook Blogs results to search page if blogs comonent is active
        if(defined( 'BP_VERSION' )){
        if(bp_is_active( 'blogs' ))
        add_action("advance-search","bpmag_show_blogs_search",10);
        }

  • Hey did you forget search for galleries 🙂 (bp-gallery plugin)

  • cool tutorial and the hack works very good, but I have a problem, or I did something wrong, I don´t get any results from my user´s blog post.

  • First day customizing a BP theme. This is exactly what I was looking for. Thanks!

  • Hi Brajesh, which part I have to update to work it with the Cosmicbuddy??????????

    • I does not require any modification in theme. You should be good to go with the plugin.

  • Brajesh

    Thank you for this code.

    I installed the zip files, but only get the results on the search. I don't get the sidebar – what do I need to do to get the sidebar?

    What is necessary to make this code search across all blogs?

    In WP 3 there is a network term that basically refers to all sub-domains in the install. I don't know if there is a network-wide search option, but that is exactly what I need on this install I have at my office.

    Suggestions?

    • hi Roy
      The wordpress/bp search will not include results from network sites.
      I think there was a plugin available for wpmu to do that(don't remember the name , will check again).

      Please check the template tags, is get_sidebar() present. Showing sidebar should be as simple as including sidebar in any other page of your theme.
      You may want to post the code in forum, so I can check why the sidebar is not appearing.

      Thanks
      Brajesh

      • Sorry Brajesh for posting this question at the bottom instead of up here…did you ever find a way to make this search include results from network sites?

        It seems like this would be critical feature…is it even possible?

        Thanks!

  • Hi Brajesh,

    The bit that searches the blog (not blogs), how can I identify that it should only search POSTS, not pages and other stuff, or at least if I can identify with specific category IDs that could help, I am sure it is a small edit to the search-loop.php.

    Looking forward.

    Cheers.

  • Hello Brajesh and thanks for the great tutorial. The functionality worked just as it says it should so I'm 90% there. I am having the same issue that roydeanjr had and that is that my sidebar is not showing up. I have not modified your templates at all yet so in search-single.php, it has included but the sidebar still does not show up. I am using WP 2.9.2 and BuddyPress 1.2.4 so I went to the page.php template and grabbed the tag and tried that too but that did not work either.

    If you have any thoughts or if I can provide you with more information, please let me know and thanks again for your hard work on this.

    • Hi Brajesh,

      I noticed the PHP did not show up in my comment so here is the revised comment…

      I have not modified your templates at all yet so in search-single.php, it has get_sidebar() included but the sidebar still does not show up. I am using WP 2.9.2 and BuddyPress 1.2.4 so I went to the page.php template and grabbed the tag locate_template( array( 'sidebar.php' ), true ) and tried that too but that did not work either.

      Thanks again!

      • hi Jess
        Sorry for delayed reply.
        Can you check via firebug the source code of the generated page, It may be some css issue.

    • Hello Jess,

      I believe the original code has been developed with WPMU in mind. Here's the modification for our WP single install. Simply replace all the following with the current code on search-single.php

      Also, replace — with the opening and closing php tags (I tweaked it so the comment will appear here).

      Good luck!

      –php get_header(); —

      –php do_action("advance-search"); // this is the only line you need —

      –php locate_template( array( 'sidebar.php' ), true ) —

      –php get_footer(); —

  • First of all thank you for the great tutorial, with which even I as a PHP noob, have managed to extend it a little bit … and I think I could give something back go the community! 😉

    If someone wants to search the activities too, you must add the following code into the functions.php:


    //show the search results for activitys */
    function bpmag_show_activity_search(){
    ?>

    Ergebnisse

    <?php
    }
    //Hook Member results to search page
    add_action("advance-search","bpmag_show_activity_search",9);

    The best thing would be a global search in the contributions of Member Blogs, too!! Maybe this is even possible …. That would be a very powerful search function!

    @Brajesh, I hope you can help me sometime with my other small problem! 🙂

    • Hmm…. da lief etwas falsch mit dem Code…

    • hi Jens
      Thanks for the comment.
      Please let me know the other problem, I will be glad to help 🙂

      • Hey Brajesh!

        I should not sitting all night long at the computer … have already written in German and the code is not complete and I still have a few problems in search of activities … please delete my comment above! 😉

        If the search results of activities are listed and you goes to the second page (if one lists 10 pieces for example), the search parameter is lost and the whole search page shows other data…

        Could you give me any help? I can gladly send you the code via email…
        then you can take it in the tutorial maybe…

        My other little problem was about the "Whois Box for WPMU" : https://buddydev.com/buddypress/creating-a-buddypress-wordpress-username-availability-checker-for-your-site/comment-page-1/#comment-3150

        🙂

        Regards, Jens

  • Brajesh,

    Is there a way to make the blogs search include all posts throughout the MU community?

  • I've tried everything to get the sidebar to show and I cannot get it to show…

    In search-single.php Currrently using the:
    -php locate_template( array( 'sidebar.php' ), true )-

    With correct tags substituted for php…

    I've tried all the things in the comment section as well.

    Interestingly when I just call the header, the sidebar, and the footer with the do action-advance-search it doesn't show the sidebar either…

    I've also changed all the divs inside the search-loop.php and same result-no sidebar…

    Any help thoughts?

  • Hello. I'm using these codes but I have a problem. When a result has more than 20, the pagination messes. And result page doesn't run AJAX. I click on Load More for the activity results, but it doesn't work. And I click to group results' 2nd page, the search term messes and 2nd page shows me the group directory. I checked the source code of the page and global.js and other ajax files are loaded. How can I run ajax? Thanks.

    • Hi Alice,
      The ajax will not work by default.
      But it is possible to ajaxify the result page. you will need to edit the js file and put the following code.

      Put follwoing code inside the jquery ready function

      jq('div.search-result').click( function(event) {
      var target = jq(event.target);

      if ( target.hasClass('button') )
      return true;

      if ( target.parent().parent().hasClass('pagination') && !target.parent().parent().hasClass('no-ajax') ) {
      if ( target.hasClass('dots') || target.hasClass('current') )
      return false;

      var page_number = 1;
      var search_container=target.parent().parent().parent();

      var item_list=jq(".item-list",jq(search_container));
      var object_arr=jq(item_list).attr("id");
      object_arr=object_arr.split("-");
      var object=object_arr[0];

      var search_terms = false;

      if ( jq('input#search-terms').length )
      search_terms = jq('input#search-terms').val();

      if ( jq(target).hasClass('next') )
      var page_number = Number( jq('div.pagination span.current',search_container).html() ) + 1;
      else if ( jq(target).hasClass('prev') )
      var page_number = Number( jq('div.pagination span.current',search_container).html() ) - 1;
      else
      var page_number = Number( jq(target).html() );

      bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope'), 'div.' + object+"-search-result", search_terms, page_number, jq.cookie('bp-' + object + '-extras') );

      return false;
      }

      });

      The edit header.php and change the search field to this one

      <input type="text" id="search-terms" name="search-terms" value="" />

      It will work in ajaxified mode, there will be no more issues of pagination/result messing..

      • sorry, the code did not went well, I will be posting it on pastebin and linking here.

        • OK, I'm waiting for the pastebin link. And where exactly should I put the code? Into the global.js or what? Thanks.

    • here is the Js code
      http://bpdev.pastebin.com/HhBBPeJL

      and here is the line which you will need to edit in header.php
      http://bpdev.pastebin.com/v8uU7G1u

      Hope that helps.

  • GENIUS! With my changes I made and listed at BuddyPress.org this is now Perfect? Where can I send a small donation of appreciation?

    Thanks.

  • One more thing. My search results page doesn't have a title. It seems as "Site Name | " After "|" I want it to write search term or at least "Search" like that: "Site Name | Search" or "Site Name | Search Results for -searchterm-"

    How can I fix title issue?
    Thanks.

    • here is a fix for title if the title is not displaying correctly
      http://bpdev.pastebin.com/iJb16NVM

      Thanks
      Brajesh

      • Title fix causes blank page error Brajesh. It didn't work for me. I added the codes into the global.js for the ajax support. It didn't work. I tried to edit header.php but couldn't see what to edit there. I couldn't make it 🙁

        • ok, I am going to put the edited header.php, global.js(from my install of bp 1.2.5.2) and the function in a zip file upload here in 5 minutes, you can simply unpack and copy.
          btw, are you using bp-default/child theme of bp-default or you are using a custom theme ?

  • Pingback:Other potentially useful BuddyPress plugins | Tech@CUNYJ

  • Brajesh,

    How can we add "activity search/updates" to the unified search? In addition to groups/forums/blogs? This is a missing component of a "unified search". Thanks…

  • Brajeht,

    Here is what Andy Peatling suggested we use to help us get the activity update search -searchable, but I can't figure out how to make this work with your above…

    -?php if ( bp_has_activities( bp_ajax_querystring( ‘activity’ ) . ‘&search_terms=’ . $searchterm) ) : ?-

    Seems like this would be fairly simple to implement, but I can't figure it out, I'm not a coder.

  • Brajesh,

    Sorry to hear about your health: I hope you are ok now. I recently joined BuddyDev to thank you with regard to supporting this… Frankly, this code adjustment alone is worth the price, even though you give it for free. Your patebin above works perfectly.

    A welcome addition that I would love to see implemented with regard to this… How can we limit the results to "X" amount per return per group (or even globally)?

    That is when I search the activity or forums, I get too many results displayed… is there anyway to limit this with your code? "X" amount before we see the "load-more" per section?

    Best regards.

  • Brajesh,
    Sorry to hear about your health: I hope you are ok now. I recently joined BuddyDev to thank you with regard to supporting this… Frankly, this code adjustment alone is worth the price, even though you give it for free. Your patebin above works perfectly.
    A welcome addition that I would love to see implemented with regard to this… How can we limit the results to “X” amount per return per group (or even globally)?
    That is when I search the activity or forums, I get too many results displayed… is there anyway to limit this with your code? “X” amount before we see the “load-more” per section?
    Best regards.

  • Hello, nice Plugin.
    I use it on my homepage: http://www.soundjournal.de but there's a litte issue.
    When you type in a searchterm and searching the page, so there's an optical error on the search-result-page at the top…
    How can I fix it?

    • HI Boede,
      You mean the date text going off in your header ?
      I guess you will need to adjust the markup of search-single.php slightly to fix that.

  • Brajesh, would it be possible to include say 'group meta' in the group's search?

    say we wanted to include the group tags, ( gtags_group_tags ) how could this be done?

    My other option is going with google custom search, though I wouldn’t pay for the ‘non-adds one’ and would really like to steer clear of external ads also being able to return the results in the ‘buddypress fashion’, ( group avatar, description.. )

    Thanks

    • Hi, Thanks for the the question. obviously the answer is yes. You can include the group meta in group search.

      To show the group meta only on search page, you can use something like this in groups/groups-loop.php, Inside the while loop

      It will show the meta only on the group search page.

      • Sorry, the code did not go through the comment. here it is on pastebin.
        http://bpdev.pastebin.com/FxrN2r3B

      • Hey Brajesh and thanks for the speedy reply, just making sure we are on the same page.

        Reading over my post, I wasn't very clear.

        What I'm trying to achieve is to be able to include the group meta in the group search.

        Say one of our groups, example:'wallmart' had the tag: 'big'

        Now if we searched for wall, wallmart.. it would return the group, but if we tried searching for the tag related to the group, 'big', no results ( groups ) would be returned.

        So im trying to be able to search for groups, by their related meta, ( group_meta )

        what would be easiest would be using the code above specific to groups and calling it in-place of the ones ( members and groups ) we removed at the begening of the tut.

        " >

        • Hey Brajesh and Nit3watch,

          Did you ever figure out a way to do this?

          I'm using the BuddyPress Group Tags plugin, and I'd like to include groups with tags that match the search query appear on my unified search page… is this do-able?

          Brajesh, are you familiar with this plug-in? I see you were helping a guy out with the Group Documents plugin; any magic code to make this work, too?

          Thanks in advance!

          Dave.

  • Ted #

    Brajesh is there a way to only search groups and posts within a group?

    • Using global forum, yes it is, but you will need to put the code for group/activity searching only and make sure to pass another argument with object=groups for activity which belongs to groups should be only visible.

  • Hi Bradesh,

    I've just installed the unified search and it's working great, only the thumbnails for the blog posts do not appear.

    http://outdoorottawa.com/search

    Any idea why? Are they supposed to?

    Thanks,
    Dave.

    • Hi Dave,
      Thank for the comment. Your search pages looks great.

      To enable thumbnail with the blog search, you will need to enable the post thumbnail feature in your theme.
      Adding a single line to your themes functions.php will do that

      add_theme_support( 'post-thumbnails' );

      You may want to read Mark's post for better detail on how to enable/use post thumbnail in a theme here http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/

      • Thanks, Bradesh, that pointed me in the right direction!

        Keep the excellent plugins coming!

        Dave.

  • Hey Brajesh,

    While I've got your attention… I also have your bp-gallery plugin running… excellent work, btw.

    Is there a way to integrate the two? So galleries with the search term in the title or description show up on the unified search page?

    Thanks,

    Dave.

  • Brajesh,

    Everything is still working great! Two final questions (for now :)…

    1. Is it possible to call the search page via url? Like outdoorottawa.com/search?='hiking' or something?

    2. Is there an easy bit of PHP i can use to make the search form appear in my template/sidebar?

    Cheers,

    Dave.

  • Ted #

    Hi Brajesh, I have a plugin so that users can upload documents within a group. is there anyway to search for those documents?

  • howdy, brajesh!

    nicely done. doesn't seem to include forum or blog tags in the search results, which would be stupendously helpful.

    did I miss something?

    • Hi Joel,
      yes, it does not includes the blog tags in the search result. You can add that by editing the search-loop.php(for blog posts).

  • grr. I've obviously done something completely wrong; I'm not getting results that look even remotely like the screen shot you posted. in fact, all I'm getting now is search results from forum topic tags; it isn't even searching the topics themselves.

    I used to think I was a decent coder. then I woke up this morning and found out the truth. any help would be appreciated.

    • Hi Joel,
      I have heard even the greatest soul sometime may act as the mundane human being, so do not let the thought die that you are a good programmer 😀

      Ok, Now to topic, are you using the updated file,
      https://buddydev.com/http//buddydev.com/public-download/unified-search-updated.zip

      Is your theme a custom one, or a child theme of buddypress ? can you please check you have included the files in your functions.php correctly.

      If you have not used the download but just copied the codes from the examples, that may be a reason.

      Please do let me know your situations.

      Thanks
      Brajesh

  • I'm using the Facelook theme, which is on the Buddypress list. I downloaded the zip file of the updated code.

    It's not clear from your instructions when you refer to 'the theme folder' if you mean the display theme, or the bp-default theme. However, I tried each (adding all functions to functions.php and adding the two search files) in bp-default and in the facelook folder, but nothing happened either way.

    (By the way, in the functions file, you instruct us to add them to cunctions.php which I assumed was a typographical error.)

    I'm looking forward to getting this working for my community. Thanks for the help.

    • Hi Joel,
      You can put the functions/theme file in either parent theme or child theme, that will make no difference in our case.

      The cuctions.php was a typo, thanks for letting me know, It should be functions.php.

      What do you get when you search, can you please put a screenshot or point me to the site if it is public ?

        • Hi Joel,
          Thanks for the image. Now I can see the issue.

          The search result pages url shown in screenshot is yoursite.com/blog/forums which is incorrect for Unified search. It simply means, the search form you are using is not having the action="yoursite.com/search" but just either empty action in the form or the search form is for forums search only.

          here is the best way to tackle it.
          1. Please check the code of search form
          2. Make sure the form looks like this, (please make sure to check the action url of form and the name of the text box matches.
          http://bpdev.pastebin.com/gr4wgp47

        • That code is identical to what's in mine.

          Where is bp_search_form_action defined? Obviously, in my form itself, the action is blank, which is wrong.

  • Brajesh,

    Revisiting this again… What is the code for adding the FORUM TAGS to be searched and included on the search results page?

    I would like to include the USER INPUTTED Forum tags as a "searchable" item to be included in the Unified Search Results… I scoured Buddypress.org for this and scrolled through the previous 90 comments here. It looks like some folks are asking for something similar, but not quite the same…

    Thanks!

  • Brajesh (or anyone),

    Polite bump on the above (revisting this again)… TY!

  • Brajesh,

    Polite bump on the question two above with regard to searching tags. TY!

    • Hi Joseph,
      Sorry for not being able to reply you earlier.
      Just checked it on my test BuddyPress installation.
      Do you mean listing topics field under that tag?
      If yes, It is possible to do so, but In that case we will be including two loops for forum topics?(one for posts matching that and another for tag). We we will need to apply filter="tag" to the ajaxstring and it will search tags for us.

      Should I post the code for that or do you meant something different ?

      Thanks
      Brajesh

  • Brajesh,

    These would be the tags inputted across the forums when a topic is posted for the first time…

    I've included two pictures of the tags I would like searchable (the 2nd picture is simply a custom showing of existing tags)

    http://mustech.net/holder/tags2.jpg
    http://mustech.net/holder/tags1.jpg

  • Brajesh,

    These would be the tags inputted across the forums when a topic is posted for the first time…

    I’ve included two pictures of the tags I would like searchable (the 2nd picture is simply a custom showing of existing tags)

    http://mustech.net/holder/tags2.png
    http://mustech.net/holder/tags1.png

    Sorry the above files were PNG and .jpg… use these links

    • Hi Joseph,
      Do you mean the list of tags for particular search term. I guess, It is not possible to search and list tags for a particular term at this moment in bbpress.

  • Brajesh,

    I'll try to be more clear…maybe it is not possible. Let's say I search for the term "trumpet" using Global Unified Search. Currently Unified Search will show me results for blog, forum posts, group, updates, members, etc. I also would like for it to return Forum Topics that have been tagged with the Search Term…

    IF NOT possible could it (is there someway to) show whether or not the tag has been USED (INPUTTED) at all? That is something like this:

    "The search-term has been used as a TAG: Click the TAG "TRUMPET" to see Forum Topic results tagged as such…"
    or: "The search-term has NOT been used as a Tag yet…"

    • Hi Joseph,
      Thanks for clarifying.
      yes, It is possible. I was taking it in a different way. It is possible to list the topics filed under the search term as tag(if that matches a tag).

      let me clean the code and put on the pastebin, will post back the links here again.

      Thanks
      Brajesh

    • Hi again,
      here is the code you need to add to functions.php
      http://bpdev.pastebin.com/t6aUBeyF

      Now after adding the above code, please make sure to copy forums/forums-loop.php and create a file named tag-topics.php with the content.
      then you will need to change a line in the tag-topics.php
      change
      [sourcecode language="php"]
      <?php if ( bp_has_forum_topics( bp_ajax_querystring( 'forums' )) ) : ?>
      [/sourcecode]

      to
      [sourcecode language="php"]
      <?php if ( bp_has_forum_topics( bp_ajax_querystring( 'forums' ) ."&type=tags") ) : ?>
      [/sourcecode]

      That will make it work.
      Please do let me know if it works or not for you.

  • That is fantastic news… we have a number of posts tagged as something relevant to the discussion topic, yet are not mentioned in the forum topic message itself… I am highly anticipating this code… TY!

    • Hi Joseph,
      Just posted the code above. seems we were writing at the same time. Please do let me know if that works for you or not ? I have tested it on my install and It is working, so I hope it goes well for you too 🙂

  • Wow, this is the BOMB! It works great! There is nothing that I know if on BP that lists tags this way via a search! I just need to spruce up some of the CSS a little for my site. I think many people will find this feature useful.

    Other users note: the tags-topic.php will reside in the theme's forums directory as well.

    The only mod I would like to see is that if tag does not exist…it states that so users will know it searched for it and did NOT find anything… //only if tag exists

    • Brajesh or Joseph, could you please tell where I should put tag-topics.php (theme folder, or theme/forums)?

      thank you.

  • hi Brajesh,

    thanks for the great code.
    I installed following codes: unified search + activities search + limit per page/max.

    Everything works well, sidebar is visible, except:

    Couldn't you say whether is it possible that because of some of these codes picture of my donation button (plugin PayPal Donations) started to disappear from time to time?

    thanks again!

    • small update.
      have to conclude that button disappears when search brings me to the page of unified search.

      • Hi,
        Can you point to the site. Is the donate button embeded using html code or some plugin is adding it with some action hook ? can you please check using firebug the code is appearing for it or not ?

  • Brajesh, please remove both comments above, now button works fine, maybe it is localhost issue.

    • Hi,
      It should go in the "forums" directory.
      Hope that helps.

      Thanks
      Brajesh

  • Hi Brajesh,

    Thank you for the code. It did just what I wanted.

    The only problem I am having is that prior to implementing it I had modified the member search to default to Alphabetical. I can't seem to get that to work since implementing your code.

    I found this on buddypress.org and was using it in functions.php…

    function members_alpha_by_default( $query_string ) {
    global $bp;

    if ( $bp->current_component == BP_MEMBERS_SLUG && !$bp->current_action)
    $query_string = 'type=alphabetical&action=alphabetical';

    return $query_string;
    }
    add_filter( 'bp_dtheme_ajax_querystring', 'members_alpha_by_default' );

    How can I add this to your code?

    Thank You!

    • Hi Grant, You will need to edit this a little more.
      here is the code of your function I have edited. That should make it work.
      http://bpdev.pastebin.com/HLWh9SGP

      Please do let me know If it does not. I will be checking it further then.

      Thanks
      Brajesh

      • Thank you for the prompt response. I'm still not producing the results I'm looking for on the members, but I think that's more me not fully understanding the way the search works and the default sort order. I appreciate your time. I won't waste your time on it until I better understand how to ask the proper question. Thanks!

  • Hello Brajesh, I have been using your search for a long time now and it's fantastic so first of all, thanks very much for your hard work on this.

    I tried to find this answer and sorry if it's trivial, but here's a quick problem I'm trying to solve. When a user searches for "Germain" on our website, the search finds "Germain St. Elementary" no problem which is great. But if a user searches for "Germain Street", the search returns no results. Is there a tweak I can make to make sure if there is a match on a single word in the search like "Germain", it will return a result?

    Thanks in advance for your time.

  • Hello, Brajesh. I'm currently developing my theme on a non-live website and using the latest BuddyPress trunk. On the latest stable this seems to work, but on the trunk version I get a Page Not Found error. Do you happen to have any idea what may be causing this? Also I have deep integrated bbPress. How would I go about including it's search results. I'm guessing I would need to query the results onto the page using it's tables as I don't know of any other way to accomplish this. Thank you for any help.

  • Hi Brajesh,

    Thank you for taking the time to create this and share it.

    1. I'm not great with code, so I was wondering if the updated unified search zip file will take care of everything like a WP plugin or if I also have to do steps 1 through 6.

    2. What if I want to pull results from multiple tags (i.e. California, New York) instead of just "California" or "New York" alone. How do I change the search results code to show all people who have "California" or "New York" in their profile?

    Thanks,

  • hi Brajesh!

    have small issue/question re unified search.
    I have non-eng Buddypress with bp-default child theme. Search is working fine for me, searching results/templates are translated well, but issue is with few words like "View All matched Groups" etc. They are not in bp-default POT, they are not detected even if I rescan my localization using codestyle-localisation plugin.

    Does it mean that somehow I have to make POT file for my child theme (as I can not simply write these words in my language, because buddypress won't display them in correct way)?

    thanks a lot!!

    • sorry, works just fine…as always, hands runs faster than head.

      • haha, no problem, I thought it was mind which used to run faster 🙂

  • Dan #

    Hi Brajesh,

    I installed this and he search was working great (default theme) however when logging in and out it shows a white screen. I remove the functions and logging in and out works fine. Though you should know.

    Dan

    • Hi Dan,
      Thanks for posting it.I am not sure of the issue as there is no code which should do that. Are you using a child theme/custom theme and which is that theme. Please do let me know, that will help to sort out the issue .

  • Great job – love it. Any way to add it to bp-custom instead of functions.php? I'm using a child theme with the bp-default theme serving as the parent and don't want to muddle with it's code.

    • Hi Chet,
      Please create a functions.php in your child theme and put the codes. It will still works. You can put the code in the bp-custom.php, but some of the code will not work, and you will always need to put the search-loop.php in theme, so better, please put these in the child theme's functions.php, that way you are not messing with the parent theme.

  • Great added feature!

    I would really like to be able to search Group Tags, which are added to "wp_bp_groups_groupmeta" table with a meta key of "gtags_group_tags".

    Goal being to show any group that has a key word in the title, description or group tag.

    Thanks for your time.

    • hi Dale,
      Thanks for the comment.

      Does group tag provides search functionality. If Group tag provides search functionality(I have not used it recently, so I am not much sure), Then we can add it.

  • Sorry for my English.
    It seems that people would work perfect but I can not.
    I use the theme "jukt-micronics-buddypress-buddypack" that depends on "bp-default".
    I have followed all the steps listed but nothing changes. I don't know what else to do.

    Help please!

    • Hi Lolo,
      If that does not work, please try using the attached file (at the bottom of post) and copy the codes from that. Does that help ?

  • Thank you for the reply Brajesh,

    It seems to search differently. It adds a /tag/ to the end of the url for groups and then using a custom search function with if {tag} get tag work from /tag/tagword/.

    Sadly it doesn't work like the forum tags where you can just add &tag= to the query. I will keep messing with it to see if i could get it to work. I was able to custom the search function, but I can only get it to either search the tags, or the name/description, not both.

    I just wish we could have a unified tag system for all components in buddypress. one day!=)

    I have noticed that search even in wordpress doesnt seem to search keywords, is that correct functionality?

  • Hey Brajesh,

    Is there a way to add results from your global forums plugin as well?

    If it matters I have deactivated groups/group forums

  • Hi Brajesh,

    Your code works great. Wondered how difficult it would be, to search forums posts as well as topics.

    Mark

    • Hi Mark,
      Thanks for the comment. As far as I see buddypress provides no way for searching/listing forum posts on search page. So, In my guess, It's not going to be easy. Though, If you are familiar with bbpress you can override buddypress forum search and make it happen .

      • Im new to wordpress actions, filters, hooks etc. Can you tell me where I can start. Im having difficulty getting my head round the structure of wordpress plugin development. ie where I can override the search, without losing the other buddypress features such as get_avatar.

      • or even how I can override/replicate the bp_forums_get_post in another plugin to return what I need.

        • Hi Mark,
          sorry I may not be very help because of my work load at the moment, but the best pointer in the direction is looking at bbpress/search.php. You can see the type of query executed and use those to override.

          Once I get some time, I will be certainly interested ion this functionality as It seems one of the essential search criteria for forum.

  • Hi Brajesh,

    with the code in place in functions.php, I'm no longer able to create Groups. Clicking 'Create a Group' in the Groups directory causes a blank page with slug '/groups/create/'. Remove the code from functions.php and all is normal again. This is tested with a child theme (with very minimal changes) and then with Default theme, with the same result.

    • Hi,
      No the search will not cause any issue like that. For example, check the demo site of BP mag, It has this search built in but we are able to create groups etc and everything works normal. Please check your other plugins. Or may be check, if there is no code error. You may try including the files from the zipped file in the post.

  • Luc #

    Hello,

    This is exactly what I was looking for… I have a question… I saw many updates, questions, code, etc… Can you please confirm the code at the top of the page is up to date with the latest version…

    Does it includes the search within the forum (text in the replies) or just results from the titles? Do the results include the tags as well??

    Lastly – Thank you very very much for your kindness and time you take helping everybody.

    Bless you,
    Luc

  • Hi Luc,
    Thanks for the kind comment:)
    yes, the code is tested to work with buddyPress 1.2.7.

    BuddyPress does not allows searching forum post reply at the moment. it only allows searching the topic title. So, only topic title are included. I have added the code for searching on the basis of tag in the comment .
    https://buddydev.com/buddypress/creating-the-sitewide-globalunified-search-page-for-your-buddypress-theme/comment-page-1/#ccomment-8972

    Please make sure to read that comment and 2 follow up comment by Mr. Joseph Pisano.

    hope that helps.
    Thanks
    Brajesh

  • Is it possible to include a search for specific profile fields? It doesn't appear that a loop exists for this. For example, I type in something within a users profile field called goals and it outputs the name of the users that also had that listed in their goals.

    So, John and Susie both have "designing websites" in their goals profile field. I search for "designing websites" and a section on the search page called "Goals" shows John and Susie.

    This is an incredible bit of code. Thanks!

    • Hi Mike,
      Thank you for the comment.
      Currently the default BuddyPress search does not allow that. As there are some changes coming in xprofile in BP 1.3, let us hope something like this gets implemented there.

      • Thanks for the quick reply. I'm currently using BP Profile Search to achieve this. I'll wait until the new versions come!

        On a side note, I'm using a group plugin that creates hierarchies of groups that we call communities. When I search for these groups, any search results turns up ALL of the groups. If I search http://www.achieveopedia.com/communities/?s=term I get an accurate search. Is there a line of code I can change to achieve these search results within the unified search page? Is the problem caused by the change in the term "groups"?

        Thanks in advance!

  • Hi Brajesh, i've tried to get the unified search to search forum posts, but gave up and decided to build my own search plugin. It does work, but it is big and hard to maintain right now. If you ever find a way to get your unified search to do this, I'd be interested to hear about it.

  • hi Brajesh,

    could you please help a bit…what is the idea of this code (?):

    <a href="" >

    for me it leads to the activity page, but shows nothing + user name near what's new…? disappears.

    it does create url example.com/activities/s=search-term, but does it really will show all matching activities (is it build in bp function/search?)?

    thank you.

    • oh, code is removed…question is re url above.

  • hmm I read through the replies not sure but i am trying to search group posts and forum posts i am not getting results http://faithnet.gonetweb.com is something wrong? i am using gradient theme i noticed in your fucntions you have bpmag referenced not sure if that is the problem can you help thanks.

  • also when i click on View All matched searches in forums i go back to the home screen no the search results but it says there is none.

  • ok disregard my last comment about view all – that was when it found no search results; which is part of my problem, i get results from blogs, but not from groups or forums.. but i do get results of forums titles, just not the posts inside the group or the forums here is my modifiedd functions.php http://pastebin.com/HAXJuB04 and the web site you can try a search itself http://faithnet.gonetweb.com thanks for your help sir i know your busy..

    • Hi Xcelguy,
      sorry for the delayed reply.

      Currently BuddyPress does not provide the functionality to search posts. It only searchs the title. That's why only the matched forum titles are shown.

      Please let me know if you need any other help.

      Thanks
      Brajesh

      • rob #

        okay thanks for getting back to me, please let me know if that ever changes that do the search i think I added something to it that is doing more of the trick… but not sure.. its not exact but getting better..

  • Thank you for such great plugin!
    I just need to add the the “usernames” to be searched as well under members… it seems to look at the real names only… any idea how to accomplish this?

    Also Im having a little issue with the pagination, I dont have the ajax read more button, I have the regular pagination links and when I click on the second page of result get messed up does anyone else have the same issue? or is just me?

    Thank you!

  • Is this tested for wordpress 3.2 and buddypres 1.2.9? I have that configuration and it doesn't work. I've noticed in other site that when a search is submitted, just a "/search" appears in the URL without parameters. In my site the search appears as a querystring /?s=somesearch&submit.x=0&submit.y=0
    any idea?
    This will happen with any theme. Can someone help please?

    • Hi Erick,
      It is tested to work with bp 1.2.9/wp 3.2.1.
      Please check if your search form is having correct markup.

      • Can you give me an example of a correct markup? Thank so much :)!

  • I'm using it in verdao.com.

    If you want to create another version with language support, can do the translation into Spanish and Portuguese.

    Thank you for your plugin once again.
    Have a great weekend.

    • Hi Jonas,
      Thanks for the comment. I will do a plugin for it(hopefully tomorrow). I hesitated earlier because of it's dependence on the theme.

      • =)

        also, i have one suggest

        I can sugest One feature for the admin plugin is the option to enable/disable features in search groups, blog, users, trends.

  • hi again Brajesh!

    as I mentioned before, I use tranposh plugin to have multilingual BP. For some reason when I search for any word with "unified search", transposh switches language of the search page back to default.

    Is it something for 100% connected to transposh, or you could have some suggestions?

    thanks!

  • don't know hot hard it is, so, will ask: is there any fast way to add live search for search box/"unified search"?

    thanks.

  • Hi Brajesh,

    Have you tested the buddydev search with buddypress 1.5 beta?

    On my test site the search is broken. It redirects to the members directory page.

    Greetings
    Svenl77

    • Hi Svenl,
      sorry I took a long time to reply. I just tested it today and indeed it does not work with BuddyPress 1.5. Bp 1.5 has changed the way the directory/root components are handles and buddypress does not provide the /search page as It used to do in 1.2.x branch. I am looking at a solution and will post the code late night today or tomorrow.

      Thanks
      Brajesh

    • Hi Sven,
      I managed to get it working with bp 1.5 but It won't be possible to do that using functions.php. It will need to be used as a plugin or some code in bp-custom.php to map the search slug to global search page. will be publishing a detailed tutorial in next couple of day. If you want to code immediately, please let me know. I will put it on github.

      • Hi Brajesh,

        Just saw your reply, I thought I will get a notification via mail, so I didn't look for an answer…

        It would be nice if you provide the code at github.

        Thanks a lot,
        Sven

        • Hi Sven,
          here is the plugin
          https://github.com/sbrajesh/bp-global-unified-search/tree/v1.0
          Sorry for my delayed update.

          If you already have the changes in your template(functions.php/search-single,search-loop.php) then you can just activate the plugin without any need to do anything. Once you activate the plugin, you will need to create a page and associate it to Search Page in BuddyPress->Pages screen. Once done, you are good to test it. Please do let me know your test results 🙂

        • Hi Brajesh,

          Thanks a lot, I haven't found any bug so far.

          Works great!

          Greetings Sven

  • I've implemented this on a customer's website but, although the rest of the search works fine, it doesn't appear to be finding any forum posts. All of the forums require membership (two are also hidden) so I imagine that non-logged in members wouldn't be able to find the topics, however, even with the administrator account and specifically typing in the name of a forum topic (exactly as it appears in the forum) doesn't get it listed on the search results.

    Do you know of any reason why that may be? I've checked my code and it is exactly the same as that you have produced above. Thanks for any help you can provide.

    • Hi Dave,
      I am sorry for the issue but I am not sure why It would not do that. Can you test the same on a standard non restricted install. It should list the forum topics.

  • Yeah Brajesh, could you update this for 1.5, and include bbPress topic support please 🙂

    • Hi Mike,
      Will certainly update in 1-2 days for bp 1.5 🙂

  • Hi Brajesh: I came across your tutorial while trying to figure out how to add/change the search function to do site wide search on our WP/PB site. We have also have added a groupon clone for deals. Will your plugin give us the site wide search for all topics – members, recipes, dishes, groups and basically any term the user wants to search?

    Thanks so much,

    Lenora

    • HI Lenora,
      Thanks for the commeent. If you have a custom component for coupons, certainly you can add them on the unified search page. Please take a look at the way we are doing it for core components. You will just nee to add a hook to include the component-loop.php from those component directory.

  • Hi Brajesh,

    Great work on the code, just dropped it in on my WP 3.2.1 / BP 1.2.9 site and worked beautifully first time, very impressive.

    There are two further things I'd like to accomplish with it. Is it possible to do either of these?

    1. Remove results for 'blogs' – I need the results for 'blog' but not 'blogs', and I'd like to remove this.

    2. As suggested above, expanding user searches to include the username as well as the display name would be useful.

    Thanks again for this excellent extension to Buddypress which I think should be part of the core functionality.

    • Hi Notpoppy,
      Thank you for the comment. I hope, Bp will have a better search functionality in core soon 🙂
      For your issues.
      1. Please comment these lines
      [sourcecode language="php"]
      if(bp_is_active( 'blogs' ))
      add_action("advance-search","bpmag_show_blogs_search",10);
      [/sourcecode]

      2. Currently not feasible as The buddyPress core does not allow searching by username at this monent.

      Hope that helps.

      • Thanks very much – got it working as I wanted now.

  • Hello again!

    I've just noticed another aspect that's not quite working as I'd hoped.

    When a person does a search and gets no results, they are still invited to "view all matched…" results for groups, posts and forums.

    This is obviously a bit confusing, because the user is being told there's no results, then invited to see more results. Can this be changed?

  • hey Brajesh thanks a lot and awesome job! I read all the previous post and saw that someone asked if it was possible to include results for group documents (from http://wordpress.org/extend/plugins/buddypress-group-documents/). I didn't see an answer response from you and tried searching this site for an answer too but no luck.

    in addition, i know BP currently cannot search for posts within a topic, but would it be possible to search for uploaded files/attachments within the topics?

  • Could you include bbPress search too, please?

  • Has bp_is_active been deprecated? I am getting fatal errors with those lines in functions.php.

  • i updated bp 1.2.10 and im getting a fatal error in my functions.php

    this line in particular

    if(bp_is_active( 'groups' ))

    please help!

  • Hi Brajesh,

    could you please add support for bbPress? I am not using BuddyPress Discussion Forums. I have bbPress and BudyyPress installed as separate plugins. Would be very thankful if you could take time to add bbPress 2.0 support. Thanx in advance

    • Hi Vato,
      Thank you for the suggestion.
      I am certainly going to include in the next version.

  • This is one epic tutorial..
    Thanks… 😀

  • So I'm having a bit of a weird issue. I've got a dev site setup here: http://wqke.coreymcollins.com/

    If you use the search form in the header, everything works fine. It gives the results styled the way I want – all is good.

    But click on any other link. Click "Photos" for instance, and a try a search from there. You wind up with no content. So, for some reason, this is only working on the front page.

    I've got everything set the way you've done in your code above, so I'm not sure what could be causing the issue.

    Running the latest versions of WP and BP. Any advice?

    Thanks!

    • So, I tinkered around some more and figured things out. I'm still having some issues, though – none of my topics are popping up in the "search forums" section.

      At first, the "search forums" section wasn't even displaying in results, so I took out this chunk of code:


      && bp_is_active( 'groups' ) && ( function_exists( 'bp_forums_is_installed_correctly' ) && !(int) bp_get_option( 'bp-disable-forum-directory' ) ) && bp_forums_is_installed_correctly()

      I did this because I'm not using groups. I tried just removing the "&& bp_is_active('groups')" portion, but the results still did not display.

      In order to get my forums to work, I had to change the Forum Settings a little bit – "Archive Slugs – Forum Base" is now "wqke" and "Single Slugs – Forum Slug" is now "wqke-single".

      Is this something that needs to be edited somewhere else in the code?

      The other thing I'm running into is on the "Members" page. No matter what I search, it just refreshes the member listing instead of actually performing a search.

      • Hi Corey,
        Are you using bbpress 2.0 ? The search does not support it yet but I am going to update it again in a couple of day to support the bbpress 2.0 search(Please keep an eye on the github repo).

        Thanks
        Brajesh

        • I am using 2.0 – I'll definitely keep an eye out for the update, thanks for the quick response!

  • I've recently switched to Buddypress v1.5 and updated the code accordingly.

    However now I don't see any results for Forums – I get results for Members, Groups, Blog and Blogs, but nothing at all for Forums. It doesn't even say "no results found".

    • OK I've found a workaround – it works if I comment out this line in functions.php:

      if ( bp_is_active( 'forums' ) && bp_is_active( 'groups' ) && ( function_exists( 'bp_forums_is_installed_correctly' ) && !(int) bp_get_option( 'bp-disable-forum-directory' ) ) && bp_forums_is_installed_correctly() )

      There must be something in there which is incorrectly causing it not to display the Forums results.

      • So this only partially works for me. If I take out that code/comment it out, I get the "Forums Search" heading, but it always tells me that I have zero results.

        I'm thinking this all has to do with my forums/slug name. After installing bbPress, it told me that my "Forums Base" (which was "forums") was a conflict with a page created by BuddyPress called "Forums". So, I changed my "Forums Base" to "wqke" and the forums began to work. Unfortunately, I can't get search results to work. Is there a spot in the forums-loop.php or these functions that I need to change to reflect the different "Forums Base" name?

    • What did you change?

  • Is it possible to search a member also by email? Let's say that instead of putting the name of the member in the field, you putt his email, and you are sent to his profile.

    • Hi Ion,
      The plugin/method is limited by the capability of BuddyPress. It works on the top of BuddyPress search. Since BuddyPress does not allow searching btby email address at the moment, this will not allow too.

  • Perhaps I've got too many things going on here, but the search does not seem to play nicely with the Additional Privacy Options plugin created by dsader: http://wordpress.org/extend/plugins/more-privacy-options/ and the Groupblog plugin: http://wordpress.org/extend/plugins/bp-groupblog/. I'm hoping to eliminate the fully private blogs from the search results. Groupblogs, attached to even Hidden groups, appear in the search results in their abridged form. Attempts to click on the blog results in a privacy dialogue (which is good), but the community can still read the first few sentences of the private blog in the search page excerpt.

    It would seem it might be just the groupblog setup that is creating the problem. A private blog does not show up if it is not associated with a group.

  • I've noticed that where it shows the results by article, it doesn't show the date for each article.

    Say the result turn up three articles from June 5th, two for June 6th and one from June 7th, it gives the following:

    Article 1 – June 7th
    Article 2 – June 6th
    Article 3 –
    Article 4 – June 5th
    Article 5 –
    Article 6 –

    i.e. It only shows each date once.

    How can it be changed to show the dates for all the results?

    • Instead of you should use:

    • Instead of [?php the_date(); ?] you should use:
      [?php echo get_the_date(); ?]

  • Hi Brajesh

    i got the invisible sidebar issue in your wired child theme. Am using 1.2.9 BP and WP 3.2.1. Unified search works well for default theme but i cant get it working for your wired child theme. Any suggestions/help?

    Thanks for your time on this.

    Regards
    Waseem

  • Hi Brajesh

    Would request your suggestions/help on one more query. Forum tags can be searched as you mentioned above.

    Is it also possible to tweak your code and do a post tag search? I mean include in the unified search to be able to search post tags?

    Kindly let me know

    Regards
    Waseem

  • Hi Brajesh,

    am using buddypress 1.5.1 and after installing the files and adding the code to functions.php and also using the plugin (https://github.com/sbrajesh/bp-global-unified-search/tree/v1.0)

    all that happens when I search is it redirects to the members directory page.

    any ideas?

  • Hi Brajesh

    regarding the invisible side bar its a conflict with the many plugins i use on my BP install. Kindly ignore it.

    Would appreicate if you can suggest any way to search post tags and any other customs posts other then the blogs.

    Thanks
    Waseem

  • Hey Brajesh,

    Recently downloaded the Mag theme and it seems the global search isn't working with Buddypress 1.5.1.

    the demo shows it working, so I imagine its running an older version of BP?

    Cheers.

  • Greetings Brajesh,

    Thank you very much for creating this and sharing it with everyone. I've installed per your readme, yet searches return results only from the "Members Directory" — and no Posts results. Any idea why this may be happening?

    Thank you very kindly in advance.
    Sincerely,
    Colin

  • Hi Brajesh, this is a great article and has worked well for me previously, I am now going through updating my theme for 1.5 have you updated the code so it works with 1.5?
    Thanks
    Emily

  • Hi Brajesh, I've downloaded the latest code from github and everything is looking great apart from Forums which are not showing up in search – I have followed the instructions in the read me file, is there anything else I can try? thanks

  • Hi great search function, I'm trying to get this to work with bp 1.5, i installed your plugin and activated but it does not work. I'm using bp 1.5, wp 3.2.1. it just goes to the members search results. I've tested this with 1.2.9 and it worked fine but I need the functionality of 1.5 so I'm trying to get your plugin to work.

    Thanks for any help,

    • Hi Brajesh, I was wondering if you know how I could do this search on the activity on the comments/replys? It would post the results the exact way, but pull results that searches in the comments/replys.

      Thank you,

  • Hi, I've tried installing and activating the plugin "global unified search" from github – I am using basic WordPress plus Buddypress.

    On the home page, the "members" dropdown is removed, so that's good, however no matter what I do I still seem to get directed to the members page (ie it still redirects to the members results page.

    The only thing I can think of is that my theme is actually a Buddypress theme (and not perhaps a traditional WP theme, so it does not appear in the "themes" folder in WP. I have uploaded the two php pages into the BP theme folder, and amended functions.php in that same folder, plus also set the Buddypress page setting to send the search results to a custom page I have built using a new "custom-search" template.

    Any ideas what might be preventing it linking to the custom search page, instead of the members page?

    Many thanks

    Alan Hill

  • Hi brajesh
    I have been using your unified search which greatly helped thank you.
    Do you know if it's possible to search on Forum post also (at the moment only topics are searched)?
    I have been searching comments and web without success.
    thx in advance

  • Installed everything, pretty simple directions. Attempted a search and just get a plain white page with nothing in it? After a search I noticed that the url is mysitename.com/search

    Looked at the code and the tag is completely empty. Seems like I'm missing something incredible simple, but can't figure out what…

  • Got the blank page fixed, working great across posts and members but wondering how to support searching of user updates?

  • @all,
    sorry for not replying earlier. I have been busy in updating some other plugins and things.
    Today, I have updated this unified search and the new update include the facility to allow searching updates/forums/topics etc.
    Please Have a look here for all the details

    https://buddydev.com/buddypress/buddypress-globalsitewide-unified-search-update-for-buddypress-1-5/
    Please reply there and I will do my best to reply back quickly.
    Thanks
    Brajesh

  • Hi, I'd just like to say I followed this latest tutorial (dated December 5th) and it worked perfectly, I even managed to customise and tweak the results. Thanks Brajesh for an excellent piece of development and full and clear details to follow to help get it integrated in our sites. Cheers, Alan

  • Hi, I am a new web developer. Your staff looks really cool.
    My question is simple, I modify my functions.php inside theme folder, but nothing changes. It seems those functions are not called. I am wondering am I put these codes in the right place?
    Thank you so much!

  • I tried to set this up here: http://www.gmznation.com/news/ and didn't have much luck. The theme I'm using didn't have a search-loop.php, so it might be related to that. Any advice would be appreciated.

  • Hi Brajesh, thanks for the tutorial. If I wanted to extend this by limiting the member search to search only the member fullname, could this easily be done?

  • I have been looking for a search plugin for buddypress for long time and was surprised and frustrated when I found no reliable results, so I'm glad I found this post.

    But this is 2015 lol will this still work on the current versions of buddypress?

    Thanks for posting this!