Grant studio-admin capabilities to WordPress administrators

WordPress administrators (manage_options) now implicitly hold every
studio-admin capability via a user_has_cap filter, so the site owner runs
the studio without being assigned the separate us_studio_admin role. The
grant persists nothing and is removed on deactivation. The us_studio_admin
role still exists for non-administrator staff and does NOT confer any core
WordPress admin powers.

Also re-gate the studio-wide "Scheduler" dashboard off manage_options onto
a new view_all_lessons capability (added to the studio-admin cap set), so a
us_studio_admin user can see it too — previously it was administrator-only.

- RoleManager: STUDIO_ADMIN_CAPS constant, CAP_VIEW_ALL_LESSONS,
  grantStudioCapsToAdministrators() user_has_cap filter
- AdminMenu + LessonController: Scheduler gated on view_all_lessons
- Docs: user-roles.md cap matrix + administrator note; lesson-booking.md
- Tests: administrators receive studio caps; non-admins do not

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
2026-06-05 12:02:54 -03:00
co-authored by Claude Opus 4.8
parent 0b0dfe8f1c
commit b4acae34a3
6 changed files with 85 additions and 16 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ class LessonController {
public function __construct( private BookingRepository $repository ) {}
public function renderAdminDashboard(): void {
if ( ! current_user_can( 'manage_options' ) ) {
if ( ! current_user_can( RoleManager::CAP_VIEW_ALL_LESSONS ) ) {
wp_die( esc_html__( 'You do not have permission to view this page.', 'unsupervised-schedular' ) );
}