WC_API_Reports::validate_request()protectedWC 2.1

Verify that the current user has permission to view reports

Метод класса: WC_API_Reports{}

Хуков нет.

Возвращает

true|WP_Error.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->validate_request( $id, $type, $context );
$id(null)
unused
По умолчанию: null
$type(null)
unused
По умолчанию: null
$context(null)
unused
По умолчанию: null

Заметки

Список изменений

С версии 2.1 Введена.

Код WC_API_Reports::validate_request() WC 7.7.2

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;
	}
}