Auth & Capabilities

Basic Auth

Use Auth::require() to gate any admin route. It redirects unauthenticated users to the login page.

wc-roles Integration

If the wc-roles addon is active, use wc_can() instead for fine-grained capability checks.

wc_can('my-addon/do_something');

Register your capabilities via the wc_capabilities filter:

Hooks::filter('wc_capabilities', function (array $caps): array {
    $caps['My Addon']['do_something'] = 'Do Something';
    return $caps;
});