diff --git a/v3/lib/endpoints/class-acf-to-rest-api-options-controller.php b/v3/lib/endpoints/class-acf-to-rest-api-options-controller.php index a64bd85..b9456f7 100644 --- a/v3/lib/endpoints/class-acf-to-rest-api-options-controller.php +++ b/v3/lib/endpoints/class-acf-to-rest-api-options-controller.php @@ -27,5 +27,23 @@ public function register_routes() { ) ); } + /** + * Check if a given request has access to get items + * + * @param WP_REST_Request $request Full data about the request. + * @return WP_Error|bool + */ + public function get_item_permissions_check( $request ) { + if ( ! current_user_can( 'manage_options' ) ) { + return new WP_Error( + 'rest_forbidden_context', + __( 'Sorry, you are not allowed to access options.', 'acf-to-rest-api' ), + array( 'status' => rest_authorization_required_code() ) + ); + } + return true; + } + } } +