WooCommerce Code Reference

RequiredCapability
in package

Declares a WordPress capability required to execute a query or mutation.

The generated resolver checks current_user_can() for every declared capability before invoking the command. If any check fails, an UNAUTHORIZED error is returned. This attribute is repeatable: apply it multiple times to require several capabilities.

Mutually exclusive with #[PublicAccess] on the same class.

Table of Contents

__construct()  : mixed
Constructor.

Methods

__construct()

Constructor.

public __construct(string $capability) : mixed
Parameters
$capability : string

A WordPress capability slug (e.g. 'manage_woocommerce').

Return values
mixed