WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_REST_Users_Controller::delete_item() public WP 4.7.0

Deletes a single user.

{} Это метод класса: WP_REST_Users_Controller{}

Хуки из метода
Возвращает

WP_REST_Response/WP_Error. Response object on success, or WP_Error object on failure.

Использование

$WP_REST_Users_Controller = new WP_REST_Users_Controller();
$WP_REST_Users_Controller->delete_item( $request );
$request(WP_REST_Request) (обязательный)
Full details about the request.

Список изменений

С версии 4.7.0 Введена.

Код WP_REST_Users_Controller::delete_item() WP 5.5.3

<?php
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 )
		);
	}

	$user = $this->get_user( $request['id'] );

	if ( is_wp_error( $user ) ) {
		return $user;
	}

	$id       = $user->ID;
	$reassign = false === $request['reassign'] ? null : absint( $request['reassign'] );
	$force    = isset( $request['force'] ) ? (bool) $request['force'] : false;

	// We don't support trashing for users.
	if ( ! $force ) {
		return new WP_Error(
			'rest_trash_not_supported',
			/* translators: %s: force=true */
			sprintf( __( "Users do not support trashing. Set '%s' to delete." ), 'force=true' ),
			array( 'status' => 501 )
		);
	}

	if ( ! empty( $reassign ) ) {
		if ( $reassign === $id || ! get_userdata( $reassign ) ) {
			return new WP_Error(
				'rest_user_invalid_reassign',
				__( 'Invalid user ID for reassignment.' ),
				array( 'status' => 400 )
			);
		}
	}

	$request->set_param( 'context', 'edit' );

	$previous = $this->prepare_item_for_response( $user, $request );

	// Include user admin functions to get access to wp_delete_user().
	require_once ABSPATH . 'wp-admin/includes/user.php';

	$result = wp_delete_user( $id, $reassign );

	if ( ! $result ) {
		return new WP_Error(
			'rest_cannot_delete',
			__( 'The user cannot be deleted.' ),
			array( 'status' => 500 )
		);
	}

	$response = new WP_REST_Response();
	$response->set_data(
		array(
			'deleted'  => true,
			'previous' => $previous->get_data(),
		)
	);

	/**
	 * Fires immediately after a user is deleted via the REST API.
	 *
	 * @since 4.7.0
	 *
	 * @param WP_User          $user     The user data.
	 * @param WP_REST_Response $response The response returned from the API.
	 * @param WP_REST_Request  $request  The request sent to the API.
	 */
	do_action( 'rest_delete_user', $user, $response, $request );

	return $response;
}