BP_REST_Group_Settings_Endpoint::get_item( WP_REST_Request $request )
Retrieve groups settings.
Description
Parameters
- $request
-
(Required) Full details about the request.
Return
(WP_REST_Response) | WP_Error List of groups object data.
Source
File: bp-groups/classes/class-bp-rest-group-settings-endpoint.php
public function get_item( $request ) { $group = $this->groups_endpoint->get_group_object( $request ); if ( empty( $group->id ) ) { return new WP_Error( 'bp_rest_group_invalid_id', __( 'Invalid group ID.', 'buddyboss' ), array( 'status' => 404, ) ); } $nav = $request->get_param( 'nav' ); $fields = array(); switch ( $nav ) { case 'group-settings': $fields = $this->get_settings_fields( $group->id ); break; case 'forum': $fields = $this->get_forum_fields( $group->id ); break; case 'courses': $fields = $this->get_courses_fields( $group->id ); break; } $fields = apply_filters( 'bp_rest_groups_setting_fields', $fields, $group->id, $nav ); if ( is_wp_error( $fields ) ) { return $fields; } if ( empty( $fields ) ) { return new WP_Error( 'bp_rest_invalid_group_setting_nav', __( 'Sorry, you are not allowed to see the group 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 a list of groups settings is fetched 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_get_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.