public function update_item_permissions_check( $request ) {

		$id = (int) $request['id'];

		if ( ! current_user_can( 'edit_user', $id ) ) {
			return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit resource.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		if ( ! empty( $request['roles'] ) && ! current_user_can( 'edit_users' ) ) {
			return new WP_Error( 'rest_cannot_edit_roles', __( 'Sorry, you are not allowed to edit roles of this resource.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		return true;
	}
public function update_item_permissions_check( $request ) {

		$id = (int) $request['id'];

		if ( ! current_user_can( 'edit_user', $id ) ) {
			return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit resource.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		if ( ! empty( $request['roles'] ) && ! current_user_can( 'edit_users' ) ) {
			return new WP_Error( 'rest_cannot_edit_roles', __( 'Sorry, you are not allowed to edit roles of this resource.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		return true;
	}
public function update_item_permissions_check ( $ request ) { $ id = ( int ) $ request [ 'id' ] ; if ( ! current_user_can ( 'edit_user' , $ id ) ) { return new WP_Error ( 'rest_cannot_edit' , __ ( 'Sorry, you are not allowed to edit resource.' ) , array ( 'status' => rest_authorization_required_code ( ) ) ) ; } if ( ! empty ( $ request [ 'roles' ] ) && ! current_user_can ( 'edit_users' ) ) { return new WP_Error ( 'rest_cannot_edit_roles' , __ ( 'Sorry, you are not allowed to edit roles of this resource.' ) , array ( 'status' => rest_authorization_required_code ( ) ) ) ; } return true ; }
Check if a given request has access update a user

@param  WP_REST_Request $request Full details about the request.
@return WP_Error|boolean
Check if a given request has access update a user