WP_REST_Users_Controller::check_reassign

Advertisement

Summery Summery

Checks for a valid value for the reassign parameter when deleting users.

Syntax Syntax

WP_REST_Users_Controller::check_reassign( int|bool $value, WP_REST_Request $request, string $param )

Description Description

The value can be an integer, ‘false’, false, or ”.

Parameters Parameters

$value

(Required) The value passed to the reassign parameter.

$request

(Required) Full details about the request.

$param

(Required) The parameter that is being sanitized.

Return Return

(int|bool|WP_Error)

Source Source

File: wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

	public function check_reassign( $value, $request, $param ) {
		if ( is_numeric( $value ) ) {
			return $value;
		}

		if ( empty( $value ) || false === $value || 'false' === $value ) {
			return false;
		}

		return new WP_Error(
			'rest_invalid_param',
			__( 'Invalid user parameter(s).' ),
			array( 'status' => 400 )
		);
	}

Advertisement

Changelog Changelog

Changelog
Version Description
4.7.0 Introduced.

Advertisement

Leave a Reply