WordPress at a glance
function is not described

WC_API_Reports::validate_request() protected WC 2.1

Verify that the current user has permission to view reports

{} It's a method of the class: WC_API_Reports{}

No Hooks.

Return

true|WP_Error.

Usage

// protected - for code of main (parent) or child class
$result = $this->validate_request( $id, $type, $context );
$id(null)
unused
$type(null)
unused
$context(null)
unused

Notes

  • See: WC_API_Resource::validate_request()

Changelog

Since 2.1 Introduced.

Code of WC_API_Reports::validate_request() WC 5.0.0

<?php
protected function validate_request( $id = null, $type = null, $context = null ) {

	if ( ! current_user_can( 'view_woocommerce_reports' ) ) {

		return new WP_Error( 'woocommerce_api_user_cannot_read_report', __( 'You do not have permission to read this report', 'woocommerce' ), array( 'status' => 401 ) );

	} else {

		return true;
	}
}