Phase 04: Job Deactivation System
- 2 plans created
- 3 total tasks defined
- Ready for execution
Plan 04-01: Deactivation form with reason capture (2 tasks)
Plan 04-02: Admin notification on deactivation (1 task)
Create deactivation form allowing providers to deactivate published jobs with required reason field, updating post status to draft.
Purpose: Give providers control to remove jobs from public view when positions are filled or no longer available, while capturing business intelligence about why jobs are being deactivated.
Output: Formidable deactivation form integrated into provider dashboard with reason capture.
Task 1: Create job deactivation form with reason field
includes/class-formidable.php
Add create_job_deactivation_form() method following established pattern from create_job_edit_form(). Check for existing form by key 'job_deactivation' to prevent duplicates. Include 2 fields: (1) deactivation_reason textarea (required, German label "Grund für Deaktivierung", description "Bitte geben Sie an, warum Sie dieses Stellenangebot deaktivieren möchten"), (2) hidden field for job_id. Configure Update Post action: post_type='job_offer', post_status='draft' (removes from public view), id_param from URL parameter 'job_id'. Map deactivation_reason field to ACF meta field 'job_deactivation_reason'. Add ownership validation hook validate_job_deactivation_ownership() following same pattern as validate_job_ownership() from Phase 03-02 - check post exists, post_type is job_offer, post_author matches current user. Submit button: "Stellenangebot deaktivieren". Success message: "Ihr Stellenangebot wurde deaktiviert." Success action: Redirect to /anbieter-dashboard/. Add get_job_deactivation_form_id() helper following established pattern.
Check class-formidable.php contains create_job_deactivation_form(), validate_job_deactivation_ownership(), and get_job_deactivation_form_id() methods. Confirm form configured with draft status update and reason field mapping.
Deactivation form created programmatically, ownership validation hook registered, form ID getter exists, Update Post action configured for draft status
Task 2: Add deactivate action to provider dashboard
templates/provider-dashboard.php
Add deactivate mode detection alongside existing edit mode: check for action=deactivate_job and job_id parameter. When in deactivate mode, render deactivation form section similar to edit section structure - heading "Stellenangebot deaktivieren", back link to dashboard, form shortcode with id_param={job_id}. In job listings table, add "Deaktivieren" button in Actions column only for published jobs (status === 'publish') - deactivate URL: add_query_arg with action=deactivate_job and job_id. Style deactivate button differently from edit/view buttons (use warning/destructive color like red/orange background). Follow same conditional rendering pattern as edit mode - show deactivation form OR listings, not both.
Dashboard template includes deactivate mode detection, deactivation form section, and deactivate button for published jobs. Verify deactivate button appears only when post_status === 'publish'.
Dashboard supports deactivation mode via URL parameters, deactivate button visible only on published jobs, form renders in place of listings when in deactivate mode
Before declaring plan complete:
- [ ] Deactivation form exists with key 'job_deactivation'
- [ ] Form has deactivation_reason textarea field (required)
- [ ] Update Post action configured to set status='draft'
- [ ] Ownership validation prevents unauthorized deactivations
- [ ] Dashboard shows "Deaktivieren" button only for published jobs
- [ ] Deactivate mode renders form instead of listings
<success_criteria>
Deactivation form created programmatically in class-formidable.php
Form includes required reason field with German labels
Ownership validation hook prevents URL tampering
Dashboard integrates deactivation workflow with conditional rendering
Published jobs show deactivate button in actions column
Form submission updates job to draft status
</success_criteria>
After completion, create `.planning/phases/04-job-deactivation-system/04-01-SUMMARY.md`:
Phase 4 Plan 1: Job Deactivation Form Summary
[Substantive one-liner - what shipped, not "phase complete"]
Accomplishments
[Key outcome 1]
[Key outcome 2]
Files Created/Modified
includes/class-formidable.php - Description
templates/provider-dashboard.php - Description
Decisions Made
[Key decisions and rationale, or "None"]
Issues Encountered
[Problems and resolutions, or "None"]
Next Step
Ready for 04-02-PLAN.md (admin notification on deactivation with reason).