WP_REST_Users_Controller::check_user_password()publicWP 4.7.0

Check a user password for the REST API.

Performs a couple of checks like edit_user() in wp-admin/includes/user.php.

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

Хуков нет.

Возвращает

Строку|WP_Error. The sanitized password, if valid, otherwise an error.

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

$WP_REST_Users_Controller = new WP_REST_Users_Controller();
$WP_REST_Users_Controller->check_user_password( $value, $request, $param );
$value(строка) (обязательный)
The password submitted in the request.
$request(WP_REST_Request) (обязательный)
Full details about the request.
$param(строка) (обязательный)
The parameter name.

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

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

Код WP_REST_Users_Controller::check_user_password() WP 6.5.2

public function check_user_password( $value, $request, $param ) {
	$password = (string) $value;

	if ( empty( $password ) ) {
		return new WP_Error(
			'rest_user_invalid_password',
			__( 'Passwords cannot be empty.' ),
			array( 'status' => 400 )
		);
	}

	if ( str_contains( $password, '\\' ) ) {
		return new WP_Error(
			'rest_user_invalid_password',
			sprintf(
				/* translators: %s: The '\' character. */
				__( 'Passwords cannot contain the "%s" character.' ),
				'\\'
			),
			array( 'status' => 400 )
		);
	}

	return $password;
}