WP_REST_Application_Passwords_Controller::get_application_password() WordPress Method

The WP_REST_Application_Passwords_Controller::get_application_password() method is used to retrieve an application password for a given user. This can be used to allow access to certain areas of the website for a specific application, without needing to provide a full set of credentials.

WP_REST_Application_Passwords_Controller::get_application_password( WP_REST_Request $request ) #

Gets the requested application password for a user.


Parameters

$request

(WP_REST_Request)(Required)The request object.


Top ↑

Return

(array|WP_Error) The application password details if found, a WP_Error otherwise.


Top ↑

Source

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

	protected function get_application_password( $request ) {
		$user = $this->get_user( $request );

		if ( is_wp_error( $user ) ) {
			return $user;
		}

		$password = WP_Application_Passwords::get_user_application_password( $user->ID, $request['uuid'] );

		if ( ! $password ) {
			return new WP_Error(
				'rest_application_password_not_found',
				__( 'Application password not found.' ),
				array( 'status' => 404 )
			);
		}

		return $password;
	}


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.