diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index 92267be..935d894 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -112,5 +112,5 @@ Plans: | 3. Job Management Core | 4/4 | Complete | 2026-01-14 | | 4. Job Deactivation System | 2/2 | Complete | 2026-01-14 | | 5. Mentor Job Board | 4/4 | Complete | 2026-01-14 | -| 6. Email Notifications | 0/3 | Not started | - | +| 6. Email Notifications | 2/3 | In progress | - | | 7. Testing & Polish | 0/3 | Not started | - | diff --git a/.planning/STATE.md b/.planning/STATE.md index bb684c9..dffc333 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -12,7 +12,7 @@ See: .planning/PROJECT.md (updated 2026-01-14) Phase: 6 of 7 (Email Notifications) Plan: 2 of 3 in current phase Status: In progress -Last activity: 2026-01-14 — Completed Plan 06-02 (Action Scheduler integration) +Last activity: 2026-01-14 — Documented Plan 06-01 (Mentor notification opt-in) Progress: ████████████░ 64% diff --git a/.planning/phases/06-email-notifications/06-01-SUMMARY.md b/.planning/phases/06-email-notifications/06-01-SUMMARY.md new file mode 100644 index 0000000..5cbe055 --- /dev/null +++ b/.planning/phases/06-email-notifications/06-01-SUMMARY.md @@ -0,0 +1,68 @@ +--- +phase: 06-email-notifications +plan: 01 +subsystem: user-management +tags: [user-preferences, notifications, opt-in, user-meta] +requires: [03-03] +provides: [mentor-notification-opt-in-system, opted-in-mentors-query] +affects: [06-03] +tech-stack: + added: [] + patterns: [user-meta-preferences, profile-hooks] +key-files: + created: [includes/class-user-preferences.php] + modified: [includes/class-ddhh-job-manager.php, ddhh-job-manager.php] +key-decisions: [] +issues-created: [] +duration: 3 min +completed: 2026-01-14 +--- + +# Phase 6 Plan 1: Mentor Notification Opt-In Summary + +**Mentor notification preference system with profile UI toggle and query helper for opted-in users** + +## Accomplishments + +- Created DDHH_JM_User_Preferences class following singleton pattern +- Added notification opt-in checkbox on subscriber user profiles (German labels) +- Implemented user meta field 'ddhh_jm_notify_new_jobs' with secure save handling +- Built get_opted_in_mentors() helper method for efficient user ID queries +- Integrated class initialization into main plugin workflow + +## Files Created/Modified + +- `includes/class-user-preferences.php` - User preferences class with profile UI and query methods +- `includes/class-ddhh-job-manager.php` - Added initialization of user preferences hooks +- `ddhh-job-manager.php` - Added require statement for user preferences class + +## Implementation Details + +**Task 1: User Preferences Class** +- Class structure: Static methods with setup_hooks() pattern +- Profile display hooks: show_user_profile and edit_user_profile (covers own profile and admin edit) +- Role filtering: Only shows for users with 'subscriber' role (mentors) +- UI label: "Benachrichtigungen über neue Stellenangebote erhalten" (German) +- Help text: "Sie erhalten eine E-Mail, wenn ein neues Stellenangebot veröffentlicht wird." +- Security: Nonce verification for all save operations +- Meta key: 'ddhh_jm_notify_new_jobs' (boolean: '1' = opted in, '0' or missing = opted out) +- Default behavior: Opt-out (users must explicitly enable) + +**Task 2: Query Helper Method** +- Method: get_opted_in_mentors() returns array of user IDs +- Query: WP_User_Query with role='subscriber' and meta_query for opt-in value +- Optimization: fields='ID' returns only IDs (efficient for batch processing) +- Error handling: Logs to error_log if query fails, returns empty array +- Ready for Phase 06-03 email batch processing + +## Decisions Made + +None - implementation followed established patterns and plan specifications exactly. + +## Issues Encountered + +None - straightforward implementation using WordPress user meta and profile hooks. + +## Next Step + +Ready for Plan 06-03 (async email batch processing on job publish). Plan 06-02 (Action Scheduler integration) is already complete and provides the async infrastructure needed.