1. Go to this page and download the library: Download billmn/craft-turnstile library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
Turnstile::getInstance()->validator->verify(); // returns `true` if passes
Turnstile::getInstance()->validator->passes();
Turnstile::getInstance()->validator->fails();
use billmn\turnstile\Turnstile;
use craft\contactform\events\SendEvent;
use craft\contactform\Mailer;
use yii\base\Event;
Event::on(
Mailer::class,
Mailer::EVENT_BEFORE_SEND,
function(SendEvent $e) {
$e->isSpam = Turnstile::getInstance()->validator->fails();
}
);