Docs / Forms & Leads

Forms & Leads

Every

on an LHAI-built page is automatically wired to collect submissions, email you, optionally forward to a webhook — and never reload the page.

How it works

LHAI-generated pages carry a _lhai_generated post-meta flag. On those pages, the plugin enqueues a tiny runtime script (about 3 KB) that:

  1. Intercepts every submit event on every <form> on the page.
  2. Serializes visible fields (buttons and file inputs excluded).
  3. POSTs to admin-ajax.php with a CSRF-style nonce.
  4. On success: fades the form out and a green checkmark card in — or redirects to your Thank-you URL if you configured one.

The form never reloads. The page HTML is unchanged. If JavaScript is disabled for the visitor, the form falls back to a normal server POST — which fails gracefully (no 500 error, just no submission).

In the Visual Editor, click any <form> and a Form Settings accordion appears near the bottom of the sidebar.

Form Settings ▴
https://hook.make.com/abc123…
/thanks
Thank you! We will be in touch soon.
⚡ Submissions are always saved to the Leads tab — the webhook and thank-you URL are optional extras.
  • Webhook URL — when set, LHAI also POSTs the submission as JSON to this URL (Zapier, Make, n8n, custom endpoint, anything that accepts a POST). The POST is non-blocking so a slow webhook doesn't delay the visitor's success screen.
  • Thank-you URL — if set, the visitor is redirected here on success instead of seeing the inline success card.
  • Success message — the text inside the inline success card. Default: "Thank you! We'll be in touch soon."

These three values are stored as data-lhai-webhook, data-lhai-thankyou, and data-lhai-success-msg attributes on the <form> element. They survive publish, edit, duplicate, and manual HTML export.

Where submissions go

Every submission writes a row to {prefix}lhai_leads in your WordPress database:

ColumnTypeNotes
idBIGINT (auto)Primary key
page_idBIGINTWP post ID of the page
page_titleVARCHAR(255)Snapshot of the page title at submission
form_dataLONGTEXTJSON — field name → sanitized value
submitted_atDATETIMEServer time, WordPress timezone
ip_addressVARCHAR(64)Respects Cloudflare & X-Forwarded-For headers
user_agentVARCHAR(500)Truncated to 500 chars
statusVARCHAR(20)new, read, or archived

Admin email notification

Every submission also fires wp_mail() to the WordPress site admin email (get_option('admin_email')). Subject: New lead from [Page Title] — LHAI. Body: an HTML table of every field plus a link back to the Leads page.

If your host has no SMTP configured, wp_mail() can silently fail. Install a transactional SMTP plugin (WP Mail SMTP, Fluent SMTP) before going live — the submission still reaches the database regardless.

The Leads admin page

Open LHAI → Leads. You'll see:

  • Three stat cards — total submissions, new (unread), distinct pages.
  • Filter bar — page dropdown, status, date range.
  • Bulk actions — mark read / mark new / archive / delete.
  • Per-row delete — for quickly removing test submissions.
  • Export CSV — UTF-8 with BOM so Excel opens Hebrew and emoji correctly. The column header is the union of every field that appeared across the exported rows.

Webhook payload

Configure Webhook URL on a form and every submission fires a POST:

POST https://hooks.zapier.com/...
Content-Type: application/json

{
    "lead_id": 47,
    "page_id": 128,
    "page_title": "Pilates Tel Aviv — Book a Trial",
    "fields": {
        "Name": "Dana",
        "Email": "[email protected]",
        "Preferred time": "Tuesday evening"
    },
    "submitted_at": "2026-04-25 14:18:02"
}

The request is fired non-blocking, so a slow or dead webhook doesn't delay the visitor's confirmation screen. The lead is still stored in your database regardless of webhook outcome.

Spam protection

LHAI injects a hidden honeypot field (lhai_hp) into every form. Bots that fill every input will trip it; the submission is silently dropped with a 200 response so the bot thinks it succeeded and moves on. No CAPTCHA required for most use cases.

Seeing spam anyway? Your form probably has an unusual field name a specific bot has seen before. Rename the offending field (or add a second honeypot with a plausible-looking name) and the attack pattern usually evaporates.

Thank-you UX

Two flows depending on how the form is configured:

  • No thank-you URL — the form fades out and a rounded green card with a checkmark fades in. Your configured success message renders inside. No reload.
  • Thank-you URL set — the visitor is redirected to that URL. Useful for conversion tracking on a dedicated thank-you page.