BP_REST_Account_Settings_Options_Endpoint::update_item( WP_REST_Request $request )
Update Account Settings options.
Description
Parameters
- $request
-
(Required) Full details about the request.
Return
(WP_Error) | WP_REST_Response
Source
File: bp-settings/classes/class-bp-rest-account-settings-options-endpoint.php
public function update_item( $request ) { $nav = $request->get_param( 'nav' ); $fields = array(); $updated = array(); switch ( $nav ) { case 'general': $updated = $this->update_general_fields( $request ); $fields = $this->get_general_fields(); break; case 'notifications': $updated = $this->update_notifications_fields( $request ); $fields = $this->get_notifications_fields(); break; case 'profile': $updated = $this->update_profile_fields( $request ); $fields = $this->get_profile_fields(); break; case 'invites': $updated = $this->update_invites_fields( $request ); $fields = $this->get_invites_fields(); break; case 'export': $updated = $this->update_export_fields( $request ); $fields = $this->get_export_fields(); break; case 'delete-account': $updated = $this->update_delete_account_fields( $request ); $fields = $this->get_delete_account_fields(); break; } $fields = apply_filters( 'bp_rest_account_setting_update_fields', $fields, $nav ); $updated = apply_filters( 'bp_rest_account_setting_update_message', $updated, $nav ); $fields_update = $this->update_additional_fields_for_object( $nav, $request ); if ( is_wp_error( $fields_update ) ) { return $fields_update; } $data = array(); if ( ! empty( $fields ) ) { foreach ( $fields as $field ) { $data[] = $this->prepare_response_for_collection( $this->prepare_item_for_response( $field, $request ) ); } } $retval = array( 'error' => ( isset( $updated['error'] ) ? $updated['error'] : false ), 'notices' => ( isset( $updated['notice'] ) ? $updated['notice'] : false ), 'data' => $data, ); $response = rest_ensure_response( $retval ); /** * Fires after account setting options are updated via the REST API. * * @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_update_item', $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.