WP_REST_Application_Passwords_Controller::get_current_item_permissions_check() WordPress Method
The WP_REST_Application_Passwords_Controller::get_current_item_permissions_check() method is used to check whether the current user has permission to retrieve the details of the specified application password. This method is called during the handling of a REST request to retrieve the details of a particular application password. The method first checks if the current user has the 'rest_application_password_read' capability. If the user does not have this capability, then the method returns false. If the user does have the 'rest_application_password_read' capability, then the method checks if the specified application password exists. If the application password does not exist, then the method returns false. Finally, if the user has the 'rest_application_password_read' capability and the specified application password exists, then the method returns true. This indicates that the current user has permission to retrieve the details of the specified application password.
WP_REST_Application_Passwords_Controller::get_current_item_permissions_check( WP_REST_Request $request ) #
Checks if a given request has access to get the currently used application password for a user.
Parameters
- $request
(WP_REST_Request)(Required)Full details about the request.
Return
(true|WP_Error) True if the request has read access for the item, WP_Error object otherwise.
Source
File: wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php
public function get_current_item_permissions_check( $request ) { $user = $this->get_user( $request ); if ( is_wp_error( $user ) ) { return $user; } if ( get_current_user_id() !== $user->ID ) { return new WP_Error( 'rest_cannot_introspect_app_password_for_non_authenticated_user', __( 'The authenticated application password can only be introspected for the current user.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.7.0 | Introduced. |