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
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | 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.