From 4726c85ee5fdfb226a175ad7f652b3ed278d9845 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Fri, 2 Dec 2016 22:16:33 +0000 Subject: [PATCH] REST API: Disable `DELETE` requests for users in multisite. In wp-admin, users are removed from individual sites rather than deleted. A user can only be deleted from the network admin. Until support for a PUT request that removes a user's site and content associations is available, DELETE requests are disabled to avoid possible issues with lost content. Merges [34938] onto 4.7 branch. Props jnylen0, rachelbaker. Fixes #38962 for 4.7. Built from https://develop.svn.wordpress.org/branches/4.7@39439 git-svn-id: http://core.svn.wordpress.org/branches/4.7@39379 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../rest-api/endpoints/class-wp-rest-users-controller.php | 5 +++++ wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php index c81d092efe..01542a9b6b 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php @@ -701,6 +701,11 @@ class WP_REST_Users_Controller extends WP_REST_Controller { * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function delete_item( $request ) { + // We don't support delete requests in multisite. + if ( is_multisite() ) { + return new WP_Error( 'rest_cannot_delete', __( 'The user cannot be deleted.' ), array( 'status' => 501 ) ); + } + $id = (int) $request['id']; $reassign = false === $request['reassign'] ? null : absint( $request['reassign'] ); $force = isset( $request['force'] ) ? (bool) $request['force'] : false; diff --git a/wp-includes/version.php b/wp-includes/version.php index 71b6c88083..c41f042978 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-RC1-39437'; +$wp_version = '4.7-RC1-39439'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.