Skip to content

Forms ​

Contact forms in the Contact Form 7 format, with Flamingo messages and mail, kept free of spam by a honeypot, Cloudflare Turnstile, hCaptcha or reCAPTCHA v3, and Akismet.

kitloom/forms · admins: kitloom/forms-filament, kitloom/forms-nova

Video lessons ​

Recorded in the Filament admin; the Nova admin works the same way.

Contact forms
Contact form messages
Contact form settings

Contact Form 7 forms on a kitloom site: the shortcodes that draw them, taking a submission, mailing it and keeping it. Forms stay where the plugin keeps them and messages where Flamingo keeps them, so a site moved from WordPress brings both along, and nothing here needs a table of its own.

The admins are kitloom/forms-filament and kitloom/forms-nova.

In the visual editor of either admin, «Shortcode» → «Contact form» picks a published form by its title and puts its shortcode into the text, the title included as Contact Form 7 writes it; a click on the shortcode there picks another form.

The data ​

WhatWhere
A forma wpcf7_contact_form post
Its template, [text* your-name] and the rest_form meta (the content keeps a copy)
Its mails_mail and _mail_2 meta: recipient, sender, subject, body, additional headers, use_html, exclude_blank, active
The texts a visitor sees_messages meta, by the plugin's keys (mail_sent_ok, invalid_required, …)
Additional settings_additional_settings meta, name: value lines
What a shortcode finds it by_hash meta, given on the first save
A messagea flamingo_inbound post: _field_<name> meta per field, _fields, _from, _subject, _meta (IP, user agent, page, date)
The form a message came fromits flamingo_inbound_channel term, under "Contact Form 7", with the form's slug

Arrays are written as JSON and read in WordPress's serialized format too.

On the site ​

[contact-form-7 id="1a2b3c4"] (or the older [contact-form id="12"]) finds the published form by the start of its hash or by its post ID. Its data for the theme is the template with each form-tag turned into a field shortcode — [text], [email], [url], [tel], [number], [date], [textarea], [select], [checkbox], [radio], [acceptance], [submit] — whose arguments say what to draw: name, value, required, placeholder, options, multiple, and the rest of the tag's options. Other tags ([file], [quiz]) stay as text.

The shortcode's data also has action: the address the theme posts the fields to, POST /wp-json/contact-form-7/v1/contact-forms/{id}/feedback — the plugin's own route, under the site's REST root (kitloom/site). The fields go as the form posts them, form-encoded or JSON, a checkbox group as a list; no session and no CSRF token, kitloom-forms.routes.throttle submissions a minute from one address (10). The answer is the plugin's:

json
{ "contact_form_id": 12, "status": "validation_failed", "message": "One or more fields have an error…",
  "invalid_fields": [{ "field": "your-email", "message": "The field is required.", "into": "span.wpcf7-form-control-wrap[data-name=\"your-email\"]" }] }

status is mail_sent, validation_failed, spam or mail_failed, always with 200; an unknown form is wpcf7_not_found (404). routes.register turns the route off.

In another language ​

With kitloom/languages a form follows the page's language: its placeholders, the choices of a list, the acceptance sentence, the buttons, the text around the fields and the messages after sending come from the form's Translations tab — one per language, with Translate with AI. A submission is checked against the words the visitor saw, and a translated choice still says in mail what the original says, so the mail you get is the same in every language. The messages a form keeps as they came — the defaults — are this package's words, translated for the visitor (lang/fr.json) until the tab says otherwise.

A form offers its words through Kitloom\WpSchema\Contracts\TranslatableTexts (FormTexts, keys like form.your-name.placeholder, form.submit.0, messages.mail_sent_ok) and reads them through TextTranslator: without a translation module the form is as written.

A submission ​

  1. Spam protection decides whether to take it at all (below). A submission made in code — Submissions::submit() without a request — is not asked.
  2. Each field is checked against its tag — required, email, URL, telephone, number and date ranges, length, a choice the form offers — and only the form's own fields are kept.
  3. The message is stored as Flamingo's, unless do_not_store: true, and Kitloom\Forms\Events\SubmissionReceived is dispatched — Contact Form 7's wpcf7_before_send_mail — with the submission and the stored message, whatever the mail does next (kitloom/notifications tells the owner).
  4. The mails are queued through the application's mailer (or kitloom-forms.mailer), mail-tags filled — [your-name], [_raw_topic], [_site_title], [_site_admin_email], [_date], [_remote_ip], [_url] — unless skip_mail: on. demo_mode: on skips both.
  5. Kitloom\Forms\Events\SubmissionSent is dispatched — Contact Form 7's wpcf7_mail_sent — with the submission and where it came from, for a module that acts on what was sent (kitloom/newsletter's "subscribe me" box). Spam, an invalid form or a failed mail never reaches it.

The pieces are public for a site that draws or takes forms its own way: Forms finds a form, Submissions takes a submission, FormProperties reads and writes a form as an admin edits it.

Spam protection ​

Up to four checks, cheapest first: the honeypot, then the captcha, then Akismet, with a limit on how often one address may send around them all. A submission that fails one gets the form's "spam" text (Your message could not be sent. unless the form changes it) and leaves no message and no mail.

Everything is set on the Settings page of the forms section in either admin (Contact → Settings in Filament, Contact Forms → Settings in Nova). Only administrators open it (the manage_contact_form_settings permission). What is saved there is used; until then the config is, so a site that keeps its keys in .env goes on as it was. Every secret and the Akismet key are stored encrypted with the application key and never shown again: leave the field empty to keep what is saved, type a new one to replace it. Agents cannot read or change them.

The honeypot ​

spatie/laravel-honeypot: a field people never see and bots fill in, and the time the form was drawn — sent sooner than HONEYPOT_SECONDS (1) after it, or with the fields missing, it is a bot. Visitors never notice it. On by default; off on the Settings page or with KITLOOM_FORMS_HONEYPOT=false. It gets along with the page cache: a cached form was only drawn earlier.

The limit ​

Submissions a minute from one address: 10 unless changed on the Settings page; 0 is no limit. One more is answered "too many requests".

The captcha ​

Choose one under Captcha: Cloudflare Turnstile (the default), hCaptcha, Google reCAPTCHA v3, or None. The chosen one works once both of its keys — a site key and a secret key — are saved; until then nothing is drawn. Only the chosen one's keys are asked for (in Nova every pair is on the page, the ones not in use say so); keys saved for another captcha stay for when you switch back.

CaptchaWhat the visitor seesWhere the keys come from
Cloudflare TurnstileMostly nothing, sometimes a box to tickdash.cloudflare.com → Turnstile → Add widget, with the site's domain
hCaptchaA box to tick, and a picture puzzle when hCaptcha is unsuredashboard.hcaptcha.com → Sites → Add new site (the site key); the secret is in the account's settings
Google reCAPTCHA v3Nothing: Google scores every submission from 0.0 (a bot) to 1.0 (a person) and one below 0.5 is refusedgoogle.com/recaptcha/admin → a new site of the type "Score based (v3)", with the site's domain; v2 keys do not work

Or in .env, used while no site key is saved for that captcha on the page (empty the site key there to go back to .env):

dotenv
KITLOOM_FORMS_CAPTCHA=turnstile          # hcaptcha, recaptcha, none
KITLOOM_FORMS_TURNSTILE_SITE_KEY=0x4AAAAAAA...
KITLOOM_FORMS_TURNSTILE_SECRET=0x4AAAAAAA...
KITLOOM_FORMS_HCAPTCHA_SITE_KEY=...
KITLOOM_FORMS_HCAPTCHA_SECRET=...
KITLOOM_FORMS_RECAPTCHA_SITE_KEY=...
KITLOOM_FORMS_RECAPTCHA_SECRET=...
KITLOOM_FORMS_RECAPTCHA_THRESHOLD=0.5

A captcha's keys go as a pair: the page's once a site key is saved there, else .env's. When the captcha's service cannot be reached, submissions are refused and the error is reported, rather than let through.

Akismet ​

Akismet reads what a message says and who sent it and tells spam from real messages — the spam a person types by hand, which a captcha lets through. It is asked last, after the honeypot and the captcha. Its key is on akismet.com, your account → API key; paste it into Akismet API key on the Settings page, which checks it with Akismet before saving and refuses one Akismet does not know. A site that came from WordPress needs nothing: while no key is saved on the page, the key WordPress's Akismet plugin saved (wordpress_api_key) is used — read, never changed. Else KITLOOM_FORMS_AKISMET_KEY in .env. No key anywhere — Akismet is not asked.

What it judges:

  • a contact form — its fields as Contact Form 7 marks them: a field with the option akismet:author is the sender's name, akismet:author_email their email, akismet:author_url their site ([text* your-name akismet:author], [email* your-email akismet:author_email]); the other text fields (text, textarea) are the message. A form with neither a message nor an author field is not sent to Akismet.
  • a comment or a review, and any other form of the site that asks the same protection — the name, email, site and words the visitor typed (a signed-in visitor's account name and email).

With every message go the visitor's address, browser and the page they came from.

A submission Akismet calls spam is refused with the form's spam text, like a failed captcha: it is not kept — there is no spam folder to look through afterwards, for messages or for comments. When Akismet cannot be reached, the message goes through and the error is reported: the honeypot and the captcha have already had their say.

Akismet learns from you: a comment marked as spam, or a contact message moved to Spam, is reported to it as spam it missed; one taken out of spam (approved, waiting for approval, or back to the Inbox) as a mistake. Spam sent to the trash teaches nothing. This is sent after the page has answered, so nobody waits for it and no queue worker is needed.

In the theme ​

The theme draws what the form's data says under protection, each null when off, and posts it with the fields:

  • honeypot (nameFieldName, validFromFieldName, encryptedValidFrom) — two inputs hidden with CSS, not type="hidden", the first left empty;
  • captcha (provider, siteKey) — turnstile: a .cf-turnstile element, which the widget fills with cf-turnstile-response; hcaptcha: an .h-captcha element, which posts h-captcha-response; recaptcha: no element — as the form is sent, grecaptcha.execute(siteKey, {action: 'submit'}) and the token posted as g-recaptcha-response;
  • turnstile (siteKey) — the same key again when the captcha is Turnstile, for a theme that knows only Turnstile.

The captcha's script lands in @siteFooter of a page that drew such a form (reCAPTCHA's with ?render=<siteKey>); a Vue or React theme loads it itself. Akismet draws nothing.

The same checks guard the site's other forms — comments, reviews, bookings — through kitloom/site's FormProtection, with the same switches and keys; a module that asks needs no forms package, and gets them once this one is installed. Akismet reads their fields under the comments' names (author_name, author_email, author_url, content).

An application with its own idea binds Contracts\SubmissionGuard: its guard replaces all the checks for the contact forms, and protection stays empty. AllowAllSubmissions takes everything, for a site that stops bots elsewhere.

AI agents ​

With kitloom/ai installed, an agent reads the forms with their shortcodes and fields (forms_list) and the messages they received (submissions_list, the inbox or the spam box) with read_contact_messages; with manage_contact_forms it reads a form's template (form_get), creates a form (form_create, mailing the site's admin email as a new form in the admin does — where messages go is a person's choice) and changes its title or template through Forms (form_update) and moves a message to the spam box or back (submission_spam). Nothing is deleted. kitloom-forms.ai.register false — no form tools.

Personal data ​

With kitloom/privacy installed, Tools → Export Personal Data hands a person every message sent from their address — the inbox, the spam and the trash: the form, the subject, when it was sent, each field by its label and where it was sent from. Erase Personal Data deletes those messages for good, as Flamingo does — a message is only what its sender wrote — and the forms' inbox counts follow. Other people's messages that mention the address are left alone. kitloom-forms.privacy.register false — the module does not take part.

Configuration ​

config/kitloom-forms.php: mailer, spam (honeypot, captcha, turnstile, hcaptcha and recaptcha with site_key, secret, timeout, recaptcha.threshold, akismet.key, akismet.test, akismet.timeout), routes (register, throttle), and the switches shortcodes.register, filament.register, nova.register, ai.register, privacy.register.

Read more ​

kitloom — sites on Laravel, built for you and run with AI.
Contact · Services · License · Refunds · Privacy · Community · YouTube · [email protected]