Spam protection
Each form has its own spam settings (form editor, Settings tab, or settings.spam in the definition):
"spam": {"honeypot": true, "timeTrapSeconds": 3, "captcha": "none", "rateLimitPerIpPerHour": 20}SpamGuard runs these checks on every submission, cheapest first:
| Check | Caught when | Spam reason |
|---|---|---|
| Trap field | The hidden _pk_website input is filled in |
honeypot |
| Minimum seconds | The form is sent sooner than timeTrapSeconds after it was shown (from the signed form token) |
time_trap |
| Per visitor and hour | One visitor (hashed IP) sent this form more than rateLimitPerIpPerHour times in the last hour |
rate_limit |
| Captcha | The provider says the answer is not real (reCAPTCHA v3: score below recaptcha_min_score) |
captcha |
A caught submission gets the same success answer as a real one, so bots learn nothing. With “store submissions” on, it is kept with status spam and meta.spam_reason, and no actions run.
0 turns the time trap and the rate limit off. The rate limit uses Symfony RateLimiter (sliding window) with the cache.app pool, and counts per form.
Captchas
Section titled “Captchas”captcha |
Provider | How it shows |
|---|---|---|
turnstile |
Cloudflare Turnstile | Widget above the submit button |
hcaptcha |
hCaptcha | Widget above the submit button |
friendly_captcha |
Friendly Captcha (v2) | Widget above the submit button |
recaptcha_v3 |
Google reCAPTCHA v3 | Invisible. The frontend script gets an answer when the form is sent |
The provider’s script is added only to pages with a form that uses it, once per page. The widget is in the theme template captcha.html.twig, which themes can override.
Get a site key and a secret key from the provider. Then either:
- enter them in Studio under PimKit > Forms > Forms settings (needs the
pimkit_settingspermission). Secrets are stored encrypted withPIMKIT_SECRET_KEYand never shown again, or - put them in the config, for example from environment variables:
pimkit_forms: captcha: turnstile: site_key: '%env(TURNSTILE_SITE_KEY)%' secret_key: '%env(TURNSTILE_SECRET_KEY)%' recaptcha_min_score: 0.5Keys saved in Studio win over the config. For Friendly Captcha the secret key is the API key.
What happens when
Section titled “What happens when”- No answer (the visitor did not solve it, or JavaScript is off): the form comes back with “Please confirm that you are not a robot.” This is not counted as spam, because a person can fix it.
- Wrong answer: spam, with a fake success.
- The form uses a captcha whose keys are missing: the form is shown and checked without a captcha, and a warning is logged. Studio shows a warning in the form’s Settings tab.
- The provider can not be reached, or says the secret is wrong: the submission is let through and a warning is logged. Losing real leads to an outage is worse than a few spam messages.
- After an AJAX submit that did not work, the frontend script resets the widget, because answers can be used only once.
The visitor’s IP address is never sent to the provider.
Headless clients
Section titled “Headless clients”Send the provider’s answer as its usual field (cf-turnstile-response, h-captcha-response, g-recaptcha-response, frc-captcha-response), as _pk_captcha, or in the X-PimKit-Captcha header.