BP_REST_Account_Settings_Options_Endpoint::get_item( WP_REST_Request $request )
Retrieve Account Settings options.
Description
Parameters
- $request
-
(Required) Full details about the request.
Return
(WP_REST_Response) | WP_Error
Source
File: bp-settings/classes/class-bp-rest-account-settings-options-endpoint.php
public function get_item( $request ) { $nav = $request->get_param( 'nav' ); $fields = array(); switch ( $nav ) { case 'general': $fields = $this->get_general_fields(); break; case 'notifications': $fields = $this->get_notifications_fields(); break; case 'profile': $fields = $this->get_profile_fields(); break; case 'invites': $fields = $this->get_invites_fields(); break; case 'export': $fields = $this->get_export_fields(); break; case 'delete-account': $fields = $this->get_delete_account_fields(); break; } $fields = apply_filters( 'bp_rest_account_setting_fields', $fields, $nav ); if ( empty( $fields ) ) { return new WP_Error( 'bp_rest_invalid_setting_nav', __( 'Sorry, you are not allowed to see the account settings options.', 'buddyboss' ), array( 'status' => 400, ) ); } $retval = array(); if ( ! empty( $fields ) ) { foreach ( $fields as $field ) { $retval[] = $this->prepare_response_for_collection( $this->prepare_item_for_response( $field, $request ) ); } } $response = rest_ensure_response( $retval ); /** * Fires after account setting options are fetched via the REST API. * * @param array $fields Fetched Fields. * @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_account_settings_options_get_item', $fields, $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.