wp_is_authorize_application_password_request_valid( array $request, WP_User $user )

Checks if the Authorize Application Password request is valid.


Parameters Parameters

$request

(array) (Required) The array of request data. All arguments are optional and may be empty.

  • 'app_name'
    (string) The suggested name of the application.
  • 'app_id'
    (string) A uuid provided by the application to uniquely identify it.
  • 'success_url'
    (string) The url the user will be redirected to after approving the application.
  • 'reject_url'
    (string) The url the user will be redirected to after rejecting the application.

$user

(WP_User) (Required) The user authorizing the application.


Top ↑

Return Return

(true|WP_Error) True if the request is valid, a WP_Error object contains errors if not.


Top ↑

Source Source

File: wp-admin/includes/user.php

function wp_is_authorize_application_password_request_valid( $request, $user ) {
	$error = new WP_Error();

	if ( ! empty( $request['success_url'] ) ) {
		$scheme = wp_parse_url( $request['success_url'], PHP_URL_SCHEME );

		if ( 'http' === $scheme ) {
			$error->add(
				'invalid_redirect_scheme',
				__( 'The success url must be served over a secure connection.' )
			);
		}
	}

	if ( ! empty( $request['reject_url'] ) ) {
		$scheme = wp_parse_url( $request['reject_url'], PHP_URL_SCHEME );

		if ( 'http' === $scheme ) {
			$error->add(
				'invalid_redirect_scheme',
				__( 'The rejection url must be served over a secure connection.' )
			);
		}
	}

	if ( ! empty( $request['app_id'] ) && ! wp_is_uuid( $request['app_id'] ) ) {
		$error->add(
			'invalid_app_id',
			__( 'The app id must be a uuid.' )
		);
	}

	/**
	 * Fires before application password errors are returned.
	 *
	 * @since 5.6.0
	 *
	 * @param WP_Error $error   The error object.
	 * @param array    $request The array of request data.
	 * @param WP_User  $user    The user authorizing the application.
	 */
	do_action( 'wp_authorize_application_password_request_errors', $error, $request, $user );

	if ( $error->has_errors() ) {
		return $error;
	}

	return true;
}


Top ↑

Changelog Changelog

Changelog
Version Description
5.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.