BP_REST_Mention_Endpoint::get_items( WP_REST_Request $request )
Retrieve members to mention.
Description
Parameters
- $request
-
(Required) Full details about the request.
Return
(WP_REST_Response) | WP_Error
Source
File: bp-core/classes/class-bp-rest-mention-endpoint.php
public function get_items( $request ) { $args = array( 'term' => sanitize_text_field( $request['term'] ), 'type' => 'members', ); if ( ! empty( $request['only_friends'] ) ) { $args['only_friends'] = absint( $request['only_friends'] ); } elseif ( bp_is_active( 'messages' ) && bp_is_active( 'friends' ) && function_exists( 'bp_force_friendship_to_message' ) && bp_force_friendship_to_message() ) { $args['only_friends'] = true; } if ( ! empty( $request['group_id'] ) ) { $args['group_id'] = absint( $request['group_id'] ); } $results = bp_core_get_suggestions( $args ); if ( is_wp_error( $results ) ) { return new WP_Error( 'bp_rest_unknown_error', $results->get_error_message(), array( 'status' => 400, ) ); } $retval = array(); foreach ( $results as $member ) { $retval[] = $this->prepare_response_for_collection( $this->prepare_item_for_response( $member, $request ) ); } $response = rest_ensure_response( $retval ); /** * Fires after a component is updated via the REST API. * * @param array $results Component info. * @param WP_REST_Response $response The response data. * @param WP_REST_Request $request The request sent to the API. * * @since 0.1.0 */ do_action( 'bp_rest_mention_items', $results, $response, $request ); return $response; }
Changelog
Version | Description |
---|---|
0.1.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.