
CrawlerDetect
Detect bots from request headers and protect forms from spam without CAPTCHA
- MODX 3
- PHP 8.2


FormIt preHook: blocks the submit if the library treats the request as a bot. Without an explicit UA it reads JayBizzle headers, not only User-Agent.
Add it to FormIt &preHooks. A direct [[!crawlerDetectBlock]] call returns "1" / "0", same as isCrawler.
If the service is unavailable, the hook returns true and the form is sent.
List other preHooks comma-separated: crawlerDetectBlock,otherHook.
crawlerDetectBlock before validation and send.false, writes fi.validation_error_message and $hook->addError('crawlerdetect', …).true.Text is set in System settings → crawlerdetect_block_message. Transport default is the Russian string «Не удалось отправить форму. Попробуйте позже.»
Output the FormIt placeholder in the form template:
[[+fi.validation_error_message]]{$modx->getPlaceholder('fi.validation_error_message')}[[!FormIt?
&preHooks=`crawlerDetectBlock`
&hooks=`email,redirect`
]]
[[+fi.validation_error_message]]
<form method="post">...</form>{$modx->runSnippet('FormIt', [
'preHooks' => 'crawlerDetectBlock',
'hooks' => 'email,redirect'
])}
{$modx->getPlaceholder('fi.validation_error_message')}
<form method="post">...</form>&preHooks=`crawlerDetectBlock,recaptcha`'preHooks' => 'crawlerDetectBlock,recaptcha'CrawlerDetect is first in the list and blocks bots before CAPTCHA.
crawlerDetectBlock to FormIt preHooks on that page. When a bot is blocked FetchIt gets an error response and shows the message from CrawlerDetect settings.si_path_to_presets). Add 'preHooks' => 'crawlerDetectBlock' to the preset. When a bot is blocked SendIt returns an error and shows the message from CrawlerDetect settings. See Integration → SendIt.crawlerDetectBlock to FormIt preHooks.