--- phase: 04-job-deactivation-system plan: 02 type: execute depends_on: ["04-01"] files_modified: [includes/class-notifications.php] --- Notify admin when provider deactivates a job, including the deactivation reason for business intelligence and quality monitoring. Purpose: Give admins visibility into deactivation patterns - whether jobs are being filled successfully, withdrawn due to problems, or removed for other reasons. This intelligence helps assess platform effectiveness. Output: Email notification sent to admin on job deactivation with reason included. ~/.claude/get-shit-done/workflows/execute-plan.md ./summary.md @.planning/PROJECT.md @.planning/ROADMAP.md @.planning/STATE.md # Prior work this plan builds on: @.planning/phases/03-job-management-core/03-03-SUMMARY.md @.planning/phases/04-job-deactivation-system/04-01-SUMMARY.md # Source files: @includes/class-notifications.php **Tech stack available:** wp_mail, transition_post_status hook, ACF field access **Established patterns:** - transition_post_status hook with status guards (new_status, old_status checks) - German email templates with job details and context - Error logging for wp_mail failures **Constraining decisions:** - Phase 03-03: transition_post_status used to detect status changes, prevents spam on updates - Phase 03-03: Email sent to admin_email option, includes direct edit link - Phase 04-01: Deactivation reason stored in ACF field 'job_deactivation_reason' - Phase 04-01: Deactivation changes post status from publish to draft Task 1: Add deactivation notification method to notifications class includes/class-notifications.php Add send_admin_job_deactivation_notification() method following same pattern as send_admin_new_job_notification(). Hook to transition_post_status with guards: post_type === 'job_offer' AND new_status === 'draft' AND old_status === 'publish' (detects only deactivations, not initial drafts). Extract deactivation reason from ACF field: get_field('job_deactivation_reason', $post_id). Email subject: "Stellenangebot deaktiviert: {job_title}". Email body (German): "Ein Stellenangebot wurde vom Anbieter deaktiviert.\n\nTitel: {job_title}\nAnbieter: {author_name} ({author_organization})\nStandort: {job_location}\nArt: {job_type}\nDeaktiviert am: {deactivation_date}\n\nGrund für Deaktivierung:\n{deactivation_reason}\n\nStelle ansehen:\n{edit_link}\n\n---\nDiese E-Mail wurde automatisch gesendet." Send to admin_email. Include error_log for missing admin_email or wp_mail failure. Register hook in setup_hooks() method following existing pattern. Check includes/class-notifications.php contains send_admin_job_deactivation_notification() method. Verify hook registered in setup_hooks(). Confirm email includes deactivation reason field. Notification method exists, hook registered, email template includes all job context plus deactivation reason, error logging present Before declaring plan complete: - [ ] Deactivation notification method exists in notifications class - [ ] Hook registered for transition_post_status with correct guards - [ ] Email includes deactivation reason from ACF field - [ ] Email sent only when status changes from publish to draft - [ ] Error logging handles missing data or wp_mail failures - Admin receives email when provider deactivates published job - Email includes job details (title, provider, location, type, date) - Email includes deactivation reason captured from form - Email sent only on publish→draft transitions (not draft→draft) - Phase 4 complete - deactivation workflow functional end-to-end After completion, create `.planning/phases/04-job-deactivation-system/04-02-SUMMARY.md`: # Phase 4 Plan 2: Deactivation Notifications Summary **[Substantive one-liner - what shipped, not "phase complete"]** ## Accomplishments - [Key outcome 1] - [Key outcome 2] ## Files Created/Modified - `includes/class-notifications.php` - Description ## Decisions Made [Key decisions and rationale, or "None"] ## Issues Encountered [Problems and resolutions, or "None"] ## Next Step Phase 4 complete. Ready for Phase 5: Mentor Job Board.