WooCommerce Code Reference

ForbiddenException extends ApiException
in package

Thrown to signal that the caller is authenticated but lacks permission to perform the requested operation, e.g. the right user but the wrong role, scope, or capability.

Use this for "I know who you are, but you can't do this." For "you need to authenticate first," prefer {@see}.

Wire shape: extensions.code = 'FORBIDDEN', HTTP status 403.

Table of Contents

__construct()  : mixed
Constructor.
getErrorCode()  : string
Get the machine-readable error code.
getExtensions()  : array<string|int, mixed>
Get the additional error metadata.
getStatusCode()  : int
Get the HTTP status code.

Methods

__construct()

Constructor.

public __construct([string $message = 'Forbidden.' ][, array<string|int, mixed> $extensions = array() ][, Throwable|null $previous = null ]) : mixed
Parameters
$message : string = 'Forbidden.'

The error message.

$extensions : array<string|int, mixed> = array()

Additional error metadata to surface in the GraphQL extensions object.

$previous : Throwable|null = null

The previous throwable for chaining.

Return values
mixed

getErrorCode()

Get the machine-readable error code.

public getErrorCode() : string
Return values
string

getExtensions()

Get the additional error metadata.

public getExtensions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getStatusCode()

Get the HTTP status code.

public getStatusCode() : int
Return values
int