rest_application_password_check_errors() WordPress Function

The rest_application_password_check_errors() function is used to check for errors when validating an application password.

rest_application_password_check_errors( WP_Error|null|true $result ) #

Checks for errors when using application password-based authentication.


Parameters

$result

(WP_Error|null|true)(Required)Error from another authentication handler, null if we should handle it, or another value if not.


Top ↑

Return

(WP_Error|null|true) WP_Error if the application password is invalid, the $result, otherwise true.


Top ↑

Source

File: wp-includes/rest-api.php

function rest_application_password_check_errors( $result ) {
	global $wp_rest_application_password_status;

	if ( ! empty( $result ) ) {
		return $result;
	}

	if ( is_wp_error( $wp_rest_application_password_status ) ) {
		$data = $wp_rest_application_password_status->get_error_data();

		if ( ! isset( $data['status'] ) ) {
			$data['status'] = 401;
		}

		$wp_rest_application_password_status->add_data( $data );

		return $wp_rest_application_password_status;
	}

	if ( $wp_rest_application_password_status instanceof WP_User ) {
		return true;
	}

	return $result;
}


Top ↑

Changelog

Changelog
VersionDescription
5.6.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.

Show More