From e324c5d585fbcfc6885a78d710c290a84ff48f16 Mon Sep 17 00:00:00 2001 From: James Griffin Date: Wed, 22 Jul 2026 11:11:22 -0300 Subject: [PATCH] Hide the My Lessons menu for users who already see Scheduler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scheduler (view_all_lessons) is a superset of My Lessons — same template, every instructor's lessons, same payment edit forms — so for an owner-operator both menu items showed the same data twice. The My Lessons menu item is now only registered for users without view_all_lessons; instructors are unaffected. Closes #85 Co-Authored-By: Claude Fable 5 --- docs/features/lesson-booking.md | 2 +- src/AdminMenu.php | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/docs/features/lesson-booking.md b/docs/features/lesson-booking.md index aa8acdb..35da9cb 100644 --- a/docs/features/lesson-booking.md +++ b/docs/features/lesson-booking.md @@ -80,7 +80,7 @@ kind `group_class`; see `group-classes.md`. ## Admin Interface - **Scheduler** (`view_all_lessons` — studio admin / administrators): all upcoming lessons across all instructors -- **My Lessons** (`view_own_lessons`): upcoming lessons for the logged-in instructor +- **My Lessons** (`view_own_lessons`): upcoming lessons for the logged-in instructor. Hidden for users who also hold `view_all_lessons` — Scheduler is a superset, so the menu item would only duplicate it. Both pages open in a **Week** calendar view by default (`usc_view`/`usc_week` query params, same pattern as the availability page, bucketed via diff --git a/src/AdminMenu.php b/src/AdminMenu.php index 36003c3..dbfcd76 100644 --- a/src/AdminMenu.php +++ b/src/AdminMenu.php @@ -233,16 +233,21 @@ class AdminMenu { 30.5 ); - // Instructor: view their upcoming lessons. - add_menu_page( - __( 'My Lessons', 'unsupervised-schedular' ), - __( 'My Lessons', 'unsupervised-schedular' ), - RoleManager::CAP_VIEW_LESSONS, - 'us-my-lessons', - [ $this->lessonController, 'renderInstructorLessons' ], - 'dashicons-welcome-learn-more', - 42 - ); + // Instructor: view their upcoming lessons. Hidden for anyone who can + // already see the Scheduler — it shows every instructor's lessons + // (including their own, with the same payment edit forms), so the two + // menu items would just duplicate each other for an owner-operator. + if ( ! current_user_can( RoleManager::CAP_VIEW_ALL_LESSONS ) ) { + add_menu_page( + __( 'My Lessons', 'unsupervised-schedular' ), + __( 'My Lessons', 'unsupervised-schedular' ), + RoleManager::CAP_VIEW_LESSONS, + 'us-my-lessons', + [ $this->lessonController, 'renderInstructorLessons' ], + 'dashicons-welcome-learn-more', + 42 + ); + } } /** -- 2.54.0