BP_REST_Group_Settings_Endpoint::update_item( WP_REST_Request $request )
Update Group Settings options.
Description
Parameters
- $request
-
(Required) Full details about the request.
Return
(WP_Error) | WP_REST_Response
Source
File: bp-groups/classes/class-bp-rest-group-settings-endpoint.php
public function update_item( $request ) { $group = $this->groups_endpoint->get_group_object( $request ); $nav = $request->get_param( 'nav' ); $fields = array(); $updated = array(); switch ( $nav ) { case 'group-settings': $updated = $this->update_settings_fields( $request ); $fields = $this->get_settings_fields( $group->id ); break; case 'forum': $updated = $this->update_forum_fields( $request ); $fields = $this->get_forum_fields( $group->id ); break; case 'courses': $updated = $this->update_courses_fields( $request ); $fields = $this->get_courses_fields( $group->id ); break; } $fields = apply_filters( 'bp_rest_group_setting_update_fields', $fields, $group->id, $nav ); $updated = apply_filters( 'bp_rest_group_setting_update_message', $updated, $group->id, $nav ); $fields_update = $this->update_additional_fields_for_object( $group->id, $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 group 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_group_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.