Notify instructors on new bookings and enrolments #205

Merged
thatguygriff merged 1 commits from feature/instructor-booking-notifications into main 2026-09-18 19:24:24 +00:00
Member

What

Adds an opt-in email notice sent to an instructor when someone books one of their private lessons or enrols in one of their group classes.

  • Off by default, per instructor. Set from My Availability → Notifications (stored as us_notify_on_booking user meta). Each instructor chooses for themselves.
  • Covers every path. Student/guardian self-service (REST) and studio-on-their-behalf (wp-admin), for both lessons and group classes.
  • Weekly reservations report how many lessons were claimed.
  • Courtesy only — a missing or failed send never fails a booking or enrolment.

How

  • Auth\InstructorNotificationPref — the per-instructor user-meta preference.
  • Auth\InstructorNotificationMailernotifyLessonBooked() / notifyEnrollment(); the opt-in check and recipient resolution are centralised here so no call site can drift on who is mailed.
  • Trigger points:
    • Booking\LessonBooker::settle() — one choke point for both lesson-booking paths.
    • GroupClass\EnrollmentEndpoint::enroll() — student/guardian enrolment.
    • GroupClass\GroupClassController::addDirect() — studio "Add students directly".
  • Availability\AvailabilityController + templates/admin/availability.php — the toggle.

New dependencies default to fresh instances, so Plugin/RestRegistrar/AdminMenu wiring is unchanged. No schema/migration, so no version bump needed.

Tests

  • New: InstructorNotificationPrefTest, InstructorNotificationMailerTest, plus enrolment/availability integration assertions.
  • Booking-path tests inject a mock mailer, keeping them about booking.
  • phpunit 1043 pass, phpstan (level 10) clean, phpcs clean.

Spec: docs/features/instructor-notifications.md. Changelog entry under [1.6.1].

## What Adds an opt-in email notice sent to an instructor when someone books one of their private lessons or enrols in one of their group classes. - **Off by default, per instructor.** Set from **My Availability → Notifications** (stored as `us_notify_on_booking` user meta). Each instructor chooses for themselves. - **Covers every path.** Student/guardian self-service (REST) and studio-on-their-behalf (wp-admin), for both lessons and group classes. - **Weekly reservations** report how many lessons were claimed. - **Courtesy only** — a missing or failed send never fails a booking or enrolment. ## How - `Auth\InstructorNotificationPref` — the per-instructor user-meta preference. - `Auth\InstructorNotificationMailer` — `notifyLessonBooked()` / `notifyEnrollment()`; the opt-in check and recipient resolution are centralised here so no call site can drift on who is mailed. - Trigger points: - `Booking\LessonBooker::settle()` — one choke point for both lesson-booking paths. - `GroupClass\EnrollmentEndpoint::enroll()` — student/guardian enrolment. - `GroupClass\GroupClassController::addDirect()` — studio "Add students directly". - `Availability\AvailabilityController` + `templates/admin/availability.php` — the toggle. New dependencies default to fresh instances, so `Plugin`/`RestRegistrar`/`AdminMenu` wiring is unchanged. No schema/migration, so no version bump needed. ## Tests - New: `InstructorNotificationPrefTest`, `InstructorNotificationMailerTest`, plus enrolment/availability integration assertions. - Booking-path tests inject a mock mailer, keeping them about booking. - `phpunit` 1043 pass, `phpstan` (level 10) clean, `phpcs` clean. Spec: `docs/features/instructor-notifications.md`. Changelog entry under `[1.6.1]`.
Kydoimos added 1 commit 2026-09-18 19:19:03 +00:00
Notify instructors on new bookings and enrolments
CI / Coding Standards (pull_request) Successful in 27s
CI / Tests (PHP 8.1) (pull_request) Successful in 37s
CI / No Debug Code (pull_request) Successful in 9s
CI / Tests (PHP 8.3) (pull_request) Successful in 36s
CI / Tests (PHP 8.5) (pull_request) Successful in 40s
CI / Tests (PHP 8.2) (pull_request) Successful in 42s
CI / Static Analysis (pull_request) Successful in 48s
CI / Build Plugin Zip (pull_request) Skipped
12765d8f13
Add an opt-in, per-instructor email notice sent when someone books one of
their lessons or enrols in one of their group classes. Off by default and
set from My Availability → Notifications; covers both the student/guardian
REST flows and the studio's wp-admin "book/add for a student" forms.

The opt-in check lives in InstructorNotificationMailer so no booking path
can drift on who is mailed; lessons fire from LessonBooker::settle (the one
step both booking paths reach), enrolments from EnrollmentEndpoint::enroll
and GroupClassController::addDirect. The notice is a courtesy and never
fails a booking or enrolment that otherwise succeeded.

Co-authored-by: anthropic/claude-opus-4-8
thatguygriff merged commit 146f63ebdd into main 2026-09-18 19:24:24 +00:00
thatguygriff deleted branch feature/instructor-booking-notifications 2026-09-18 19:24:24 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Unsupervised/unsupervised-scheduler#205