Make WP admins instructors too, and add an Access toggle page
CI / No Debug Code (pull_request) Successful in 3s
CI / Tests (PHP 8.2) (pull_request) Successful in 41s
CI / Tests (PHP 8.3) (pull_request) Successful in 51s
CI / Tests (PHP 8.1) (pull_request) Successful in 54s
CI / Coding Standards (pull_request) Successful in 58s
CI / PHPStan (pull_request) Successful in 1m9s
CI / Build Plugin Zip (pull_request) Has been skipped
CI / No Debug Code (pull_request) Successful in 3s
CI / Tests (PHP 8.2) (pull_request) Successful in 41s
CI / Tests (PHP 8.3) (pull_request) Successful in 51s
CI / Tests (PHP 8.1) (pull_request) Successful in 54s
CI / Coding Standards (pull_request) Successful in 58s
CI / PHPStan (pull_request) Successful in 1m9s
CI / Build Plugin Zip (pull_request) Has been skipped
A WordPress administrator previously inherited the studio-admin capabilities but not `manage_availability`, so the studio owner running as an admin had no way to reach "My Availability" or act as the instructor — breaking single-instructor businesses. Grant the instructor capabilities to administrators as well (via the existing `user_has_cap` filter), and make both grants — studio-admin and instructor — independently toggleable from a new Access admin page. - RoleManager: extract `INSTRUCTOR_CAPS`; apply studio and instructor cap sets to administrators, each gated on a stored toggle (default on). - AccessSettings + templates/admin/access.php: two options (`us_admin_grant_studio` / `us_admin_grant_instructor`), gated on the core `manage_options` capability so disabling a grant can never lock an administrator out of re-enabling it. - AdminMenu: register the Access page after Studio Settings; keep the studio sidebar separator visible for any administrator. - Tests for the toggles and the new settings reader; docs updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -16,11 +16,22 @@ Runs the studio. Logs in via standard wp-admin. Can:
|
||||
**Capabilities:** `read`, `manage_instructors`, `manage_offerings`, `manage_questions`, `manage_policies`, `manage_billing`, `view_all_lessons`, `view_all_payments`, `export_payments`
|
||||
|
||||
> Any WordPress **administrator** (`manage_options`) implicitly holds every
|
||||
> studio-admin capability above, so the site owner runs the studio without being
|
||||
> assigned the `us_studio_admin` role. This is applied dynamically via the
|
||||
> `user_has_cap` filter (`RoleManager::grantStudioCapsToAdministrators()`) — it
|
||||
> persists nothing and is removed when the plugin is deactivated. The
|
||||
> `us_studio_admin` role exists for non-administrator staff who manage the studio.
|
||||
> studio-admin capability above **and the instructor capabilities** (notably
|
||||
> `manage_availability`), so a single-instructor studio owner can run the business
|
||||
> and teach — managing their own availability and lessons — from one account,
|
||||
> without being assigned the `us_studio_admin` or `us_instructor` role. This is
|
||||
> applied dynamically via the `user_has_cap` filter
|
||||
> (`RoleManager::grantStudioCapsToAdministrators()`) — it persists nothing and is
|
||||
> removed when the plugin is deactivated. The `us_studio_admin` role exists for
|
||||
> non-administrator staff who manage the studio.
|
||||
>
|
||||
> Both grants can be turned off independently on the **Access** admin page
|
||||
> (`AccessSettings`, options `us_admin_grant_studio` / `us_admin_grant_instructor`,
|
||||
> both default on) — for example, when dedicated `us_studio_admin` or
|
||||
> `us_instructor` accounts run the studio and administrators should not appear as
|
||||
> studio staff. That page is gated on the core `manage_options` capability (which
|
||||
> the plugin never grants or revokes), so an administrator can always reach it to
|
||||
> re-enable a grant; disabling one can never lock them out.
|
||||
|
||||
### Instructor (`us_instructor`)
|
||||
Created by the studio admin. Logs in via standard wp-admin. Can:
|
||||
|
||||
Reference in New Issue
Block a user