WP_REST_Users_Controller::check_reassign() WordPress Method

The WP_REST_Users_Controller::check_reassign() method is used to check if a user can be reassigned to another user. This is typically used when a user is deleted and another user needs to take over their account.

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

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


Description

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


Top ↑

Parameters

$value

(int|bool)(Required)The value passed to the reassign parameter.

$request

(WP_REST_Request)(Required)Full details about the request.

$param

(string)(Required)The parameter that is being sanitized.


Top ↑

Return

(int|bool|WP_Error)


Top ↑

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


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.