bp_ps_parse_request( $request )
Parse BuddyBoss profile search request.
Description
Source
File: bp-core/profile-search/bps-fields.php
function bp_ps_parse_request ($request) { $j = 1; $parsed = array (); list (, $fields) = bp_ps_get_fields (); foreach ($fields as $key => $value) $parsed[$key] = clone $fields[$key]; foreach ($request as $key => $value) { if ($value === '') continue; $k = bp_ps_match_key ($key, $parsed); if ($k === false) continue; $f = $parsed[$k]; $filter = ($key == $f->code)? '': substr ($key, strlen ($f->code) + 1); if (!bp_ps_is_filter ($filter, $f)) continue; switch ($filter) { default: $f->filter = $filter; $f->value = $value; break; case 'distance': if (!empty ($value['location']) && !empty ($value['lat']) && !empty ($value['lng'])) { if (empty ($value['distance'])) $value['distance'] = 1; $f->filter = $filter; $f->value = $value; } break; case 'range': if (is_numeric ($value['min'])) $f->value['min'] = $value['min']; if (is_numeric ($value['max'])) $f->value['max'] = $value['max']; if (isset ($f->value)) $f->filter = $filter; break; case 'date_range': $range_types = array( 'min', 'max' ); foreach ( $range_types as $range_type ) { if ( isset( $value[ $range_type ] ) && !empty( $value[ $range_type ] ) ) { $f->value[ $range_type ]['day'] = isset( $value[ $range_type ]['day'] ) ? $value[ $range_type ]['day'] : 0; $f->value[ $range_type ]['year'] = isset( $value[ $range_type ]['year'] ) ? (int) $value[ $range_type ]['year'] : 0; $f->value[ $range_type ]['month'] = isset( $value[ $range_type ]['month'] ) ? $value[ $range_type ]['month'] : ''; //if year is not set, we reset month and day as well if ( empty( $f->value[ $range_type ]['year'] ) ) { $f->value[ $range_type ]['month'] = ''; $f->value[ $range_type ]['day'] = ''; } //if month is not set, we reset day if ( empty( $f->value[ $range_type ]['month'] ) ) { $f->value[ $range_type ]['day'] = ''; } } } $f->filter = $filter; break; case 'range_min': if (!is_numeric ($value)) break; $f->filter = rtrim ($filter, '_min'); $f->value['min'] = $value; break; case 'range_max': if (!is_numeric ($value)) break; $f->filter = rtrim ($filter, '_max'); $f->value['max'] = $value; break; case 'date_range_min': $range_types = array( 'min' ); foreach ( $range_types as $range_type ) { if ( isset( $value[ $range_type ] ) && !empty( $value[ $range_type ] ) ) { $f->value[ $range_type ]['day'] = isset( $value[ $range_type ]['day'] ) ? $value[ $range_type ]['day'] : 0; $f->value[ $range_type ]['year'] = isset( $value[ $range_type ]['year'] ) ? (int) $value[ $range_type ]['year'] : 0; $f->value[ $range_type ]['month'] = isset( $value[ $range_type ]['month'] ) ? $value[ $range_type ]['month'] : ''; //if year is not set, we reset month and day as well if ( empty( $f->value[ $range_type ]['year'] ) ) { $f->value[ $range_type ]['month'] = ''; $f->value[ $range_type ]['day'] = ''; } //if month is not set, we reset day if ( empty( $f->value[ $range_type ]['month'] ) ) { $f->value[ $range_type ]['day'] = ''; } } } $f->filter = $filter; break; case 'date_range_max': $range_types = array( 'max' ); foreach ( $range_types as $range_type ) { if ( isset( $value[ $range_type ] ) && !empty( $value[ $range_type ] ) ) { $f->value[ $range_type ]['day'] = isset( $value[ $range_type ]['day'] ) ? $value[ $range_type ]['day'] : 0; $f->value[ $range_type ]['year'] = isset( $value[ $range_type ]['year'] ) ? (int) $value[ $range_type ]['year'] : 0; $f->value[ $range_type ]['month'] = isset( $value[ $range_type ]['month'] ) ? $value[ $range_type ]['month'] : ''; //if year is not set, we reset month and day as well if ( empty( $f->value[ $range_type ]['year'] ) ) { $f->value[ $range_type ]['month'] = ''; $f->value[ $range_type ]['day'] = ''; } //if month is not set, we reset day if ( empty( $f->value[ $range_type ]['month'] ) ) { $f->value[ $range_type ]['day'] = ''; } } } $f->filter = $filter; break; case 'label': $f->label = stripslashes ($value); break; } if (!isset ($f->order)) $f->order = $j++; } return $parsed; }
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.