$npx -y skills add Lonsdale201/wp-agent-skills --skill fluentform-submission-lifecycleImplements and audits Fluent Forms server-side submission behavior from parsed field data through sanitization, validation, persistence, entry details, notifications, integrations, and confirmation. Selects the correct fluentform/input_data_*, fluentform/validation_errors, fluent
| 1 | # Fluent Forms submission lifecycle |
| 2 | |
| 3 | Choose hooks from the actual server-side order. Browser data is untrusted, and |
| 4 | an action that sounds “before insert” is not a replacement for validation. |
| 5 | |
| 6 | Read [hook-order.md](references/hook-order.md) before changing stored values, |
| 7 | adding a remote side effect, handling payment forms, or reacting to Pro drafts. |
| 8 | |
| 9 | ## Canonical lifecycle |
| 10 | |
| 11 | ```text |
| 12 | raw serialized request |
| 13 | -> form field parsing and accepted-key allowlist |
| 14 | -> recursive Fluent Forms sanitization |
| 15 | -> restrictions / CAPTCHA / input normalization / validation |
| 16 | -> spam checks |
| 17 | -> response-data and insert-row filters |
| 18 | -> submission row insert |
| 19 | -> before-actions hook |
| 20 | -> entry-details projection |
| 21 | -> submission-inserted hooks and feeds |
| 22 | -> confirmation filters |
| 23 | ``` |
| 24 | |
| 25 | Unknown request keys are removed before validation unless explicitly placed on |
| 26 | Fluent Forms' protocol-key allowlist. The accepted `$formData` is therefore not |
| 27 | the same object as raw `$_POST` or the controller's parsed input. |
| 28 | |
| 29 | ## Hook selection |
| 30 | |
| 31 | | Need | Use | Important timing | |
| 32 | |---|---|---| |
| 33 | | Normalize one element before rules | `fluentform/input_data_{element}` | Before validator | |
| 34 | | Change rule/message definitions | `fluentform/validations` | Before validator | |
| 35 | | Add cross-field errors | `fluentform/validation_errors` | Before rejection/insert | |
| 36 | | Change accepted response data | `fluentform/insert_response_data` | After validation, before JSON encode | |
| 37 | | Change DB row columns | `fluentform/filter_insert_data` | Low-level, immediately before insert | |
| 38 | | Observe imminent insert | `fluentform/before_insert_submission` | Action, after validation; cannot return changed data | |
| 39 | | React to a durable entry | `fluentform/submission_inserted` | Row and entry details exist | |
| 40 | | Change browser confirmation | `fluentform/submission_confirmation` | Last response stage | |
| 41 | |
| 42 | Do not use `fluentform/before_insert_submission` for normal validation. In 6.2.7 |
| 43 | it is an action after `handleValidation()` and receives `$insertData` by value. |
| 44 | Use validation filters so the browser gets field-shaped errors and no row is |
| 45 | created. |
| 46 | |
| 47 | ## Form-scoped cross-field validation |
| 48 | |
| 49 | ```php |
| 50 | add_filter( |
| 51 | 'fluentform/validation_errors', |
| 52 | static function ($errors, $formData, $form, $fields) { |
| 53 | if ((int) $form->id !== 42) { |
| 54 | return $errors; |
| 55 | } |
| 56 | |
| 57 | $start = (string) ($formData['start_date'] ?? ''); |
| 58 | $end = (string) ($formData['end_date'] ?? ''); |
| 59 | |
| 60 | if ($start !== '' && $end !== '' && $end < $start) { |
| 61 | $errors['end_date'][] = __( |
| 62 | 'The end date must not precede the start date.', |
| 63 | 'acme-addon' |
| 64 | ); |
| 65 | } |
| 66 | |
| 67 | return $errors; |
| 68 | }, |
| 69 | 10, |
| 70 | 4 |
| 71 | ); |
| 72 | ``` |
| 73 | |
| 74 | Use exact field names from the form definition. Preserve existing errors and |
| 75 | return an array keyed by the input name. Validate dates or numbers semantically; |
| 76 | the short comparison above is valid only for normalized ISO dates. |
| 77 | |
| 78 | ## Stored-value transformation |
| 79 | |
| 80 | ```php |
| 81 | add_filter( |
| 82 | 'fluentform/insert_response_data', |
| 83 | static function ($formData, $formId, $inputConfigs) { |
| 84 | if ((int) $formId !== 42 || !isset($formData['customer_code'])) { |
| 85 | return $formData; |
| 86 | } |
| 87 | |
| 88 | $formData['customer_code'] = strtoupper( |
| 89 | sanitize_text_field((string) $formData['customer_code']) |
| 90 | ); |
| 91 | |
| 92 | return $formData; |
| 93 | }, |
| 94 | 10, |
| 95 | 3 |
| 96 | ); |
| 97 | ``` |
| 98 | |
| 99 | This filter runs after field validation. Revalidate any materially changed value, |
| 100 | or normalize it earlier with `input_data_{element}`. Never inject secrets, |
| 101 | payment tokens, raw request bodies, or unbounded payloads into `response`. |
| 102 | |
| 103 | ## Durable side effects |
| 104 | |
| 105 | ```php |
| 106 | add_action( |
| 107 | 'fluentform/submission_inserted', |
| 108 | static function ($entryId, $formData, $form): void { |
| 109 | if ((int) $form->id !== 42) { |
| 110 | return; |
| 111 | } |
| 112 | |
| 113 | $alreadyDone = \FluentForm\App\Helpers\Helper::getSubmissionMeta( |
| 114 | $entryId, |
| 115 | '_acme_synced', |
| 116 | false |
| 117 | ); |
| 118 | |
| 119 | if ($ |