bp_ps_search( $request, $users = null )
Returns BuddyBoss Profile Search results.
Description
Source
File: bp-core/profile-search/bps-search.php
function bp_ps_search ( $request, $users = null ) { $results = array ( 'users' => array ( 0 ), 'validated' => true ); $fields = bp_ps_parse_request( $request ); $copied_arr = array(); foreach ( $fields as $f ) { if ( !isset( $f->filter ) ) continue; if ( !is_callable( $f->search ) ) continue; $f = apply_filters( 'bp_ps_field_before_query', $f ); $found = call_user_func( $f->search, $f ); $found = apply_filters( 'bp_ps_field_search_results', $found, $f ); $copied_arr = $found; if ( isset( $copied_arr ) && !empty( $copied_arr ) ) { foreach ( $copied_arr as $key => $user ) { $field_visibility = xprofile_get_field_visibility_level( intval( $f->id ), intval( $user ) ); if ( 'adminsonly' === $field_visibility && ! current_user_can( 'administrator' ) ) { if ( ( $key = array_search( $user, $found ) ) !== false ) { unset( $found[ $key ] ); } } if ( 'friends' === $field_visibility && ! current_user_can( 'administrator' ) && false === friends_check_friendship( intval( $user ), bp_loggedin_user_id() ) ) { if ( ( $key = array_search( $user, $found ) ) !== false ) { unset( $found[ $key ] ); } } } } $match_all = apply_filters( 'bp_ps_match_all', true ); if ( $match_all ) { $users = isset( $users ) ? array_intersect( $users, $found ) : $found; if ( count( $users ) == 0 ) return $results; } else { $users = isset( $users ) ? array_merge( $users, $found ) : $found; } } if ( isset( $users ) ) $results[ 'users' ] = $users; else $results[ 'validated' ] = false; return $results; }
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.