---
phase: 02-provider-registration-auth
plan: 01
type: execute
depends_on: []
files_modified: [includes/class-formidable.php]
---
Create Formidable Forms registration form with auto-login and provider role assignment.
Purpose: Enable external organizations to self-register as providers without admin intervention.
Output: Working registration form (F1) that creates WordPress users with ddhh_provider role and logs them in automatically.
~/.claude/get-shit-done/workflows/execute-plan.md
./summary.md
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/01-foundation-setup/01-03-SUMMARY.md
**From Phase 1:**
- Provider role `ddhh_provider` exists with capabilities: read, edit_job_offers, delete_job_offers, upload_files
- Role explicitly denies: publish_job_offers, edit_others_job_offers, edit_posts, edit_pages
- German UI required (v1)
**Tech stack:** Formidable Forms Pro with Registration Add-on available
Task 1: Create Formidable registration form
N/A (Formidable forms stored in WP database)
Create Formidable form via WordPress admin:
- Form name: "Provider Registration" (Anbieter-Registrierung)
- Fields (all required):
1. organization_name (text) - Label: "Organisationsname"
2. contact_person (text) - Label: "Ansprechperson"
3. email (email) - Label: "E-Mail"
4. password (password) - Label: "Passwort"
5. password_confirm (password) - Label: "Passwort bestätigen"
- German field labels per PROJECT.md
- Email field: unique validation (WordPress user_email must be unique)
- Password fields: min 8 characters, must match
Create helper class `includes/class-formidable.php` with static method get_registration_form_id() that returns the form ID (for use in shortcodes).
DO NOT use Formidable's default English labels - all labels must be German.
Form appears in Formidable Forms list, fields have German labels, email validation set to unique
Registration form created with 5 fields, all required, German labels, email uniqueness enforced
Task 2: Configure auto-login and role assignment
includes/class-formidable.php
In class-formidable.php, create static method setup_registration_hooks():
Hook into Formidable's `frm_after_create_entry` action:
- Check if form_id matches registration form
- Extract email and password from entry
- Create WordPress user with wp_insert_user():
- user_login: email prefix (before @)
- user_email: email from form
- user_pass: password from form
- role: 'ddhh_provider' (from Phase 1)
- display_name: contact_person from form
- Store organization_name as user meta 'ddhh_org_name'
- Auto-login user with wp_set_auth_cookie($user_id, true)
- Prevent duplicate submissions: check if email exists before creating user
Hook this to 'init' action in main class.
DO NOT assign 'subscriber' role - only 'ddhh_provider' role from Phase 1.
DO NOT send WordPress default registration email - providers should be logged in immediately.
Create test user via form, check user appears in WP users with ddhh_provider role, auto-login occurs (user is logged in after submission)
Form submission creates user with ddhh_provider role, auto-logs in user, stores org name as meta, no duplicate users created
Before declaring plan complete:
- [ ] Registration form exists in Formidable with German labels
- [ ] Email field enforces uniqueness
- [ ] Form submission creates WordPress user with ddhh_provider role
- [ ] User is automatically logged in after registration
- [ ] Organization name stored as user meta
- [ ] No duplicate users created on re-submission
- All tasks completed
- Form functional and creates users
- Auto-login works
- Role assignment correct (ddhh_provider)
- Ready for 02-02 (registration page integration)