Buddypress: Profile Search

33 Views Asked by At

How exactly is the member / profile search in Buddypress performed? It seems there is a cookie stored which is named bp_ps_request - I'm wondering if the search is ONLY stored on userside or also somewhere in the database?

If only the former (userside cookie) is used - are the search request UserIDs which do match the request, also stored somewhere or are they freshly derived via the Search-Filters (stored in the Cookie) everytime you open the loop?

Background of the question is: I want to show the same, filtered members shown in the Members Loop on a separate page via a different kind of view. Means: I need to find the exact UserIds which are found in the normal Members Loop.

My starting point would be:

  1. Read Cookie
  2. Parse Request String from Cookie
  3. Trigger internal "search" and return UserIDs bp_ps_search()

Something like this, adopted from the function bp_ps_get_request(), roughly like this:

$cookie  = apply_filters( 'bp_ps_cookie_name', 'bp_ps_request' );
if (isset( $_COOKIE[ $cookie ] ) ) {
    parse_str( stripslashes( $_COOKIE[ $cookie ] ), $request );
}

if($request)
{
    $results = bp_ps_search($request);
    if($results['validated']) {
        $users = $results['users'];
    }
}

Anything else to consider?

0

There are 0 best solutions below