
CrawlerDetect
Detect web crawlers by User-Agent and protect forms from spam without CAPTCHA


FormIt preHook: blocks form submission if the request is from a bot (by User-Agent). The form is not validated or processed further; the user sees the message from settings.
Usage: add crawlerDetectBlock to FormIt’s preHooks parameter.
If you already have other preHooks, list them comma-separated: crawlerDetectBlock,otherHook.
crawlerDetectBlock before validation and send.crawlerdetect_block_message is shown.Text is set in System settings → crawlerdetect_block_message. Default: "Failed to submit form. Please try again later."
Output in the form template via FormIt placeholder:
[[+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'
])}
{if $modx->getPlaceholder('fi.validation_error_message')}
<div class="error">{$modx->getPlaceholder('fi.validation_error_message')}</div>
{/if}
<form method="post">...</form>&preHooks=`crawlerDetectBlock,recaptcha`'preHooks' => 'crawlerDetectBlock,recaptcha'CrawlerDetect runs first 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 — protection will work.