PHP code example of jalendport / craft-altcha

1. Go to this page and download the library: Download jalendport/craft-altcha 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/ */

    

jalendport / craft-altcha example snippets


use Craft;
use jalendport\altcha\events\VerifyCommentEvent;
use jalendport\altcha\integrations\Comments;
use yii\base\Event;

Event::on(
    Comments::class,
    Comments::EVENT_BEFORE_VERIFY_COMMENT,
    function(VerifyCommentEvent $event) {
        if (Craft::$app->getUser()->getIdentity()) {
            $event->skipVerification = true;
        }
    },
);



return [
    'hmacKey' => '$ALTCHA_HMAC_KEY',
    'challengeExpiryMinutes' => 20,
    'complexity' => 50000,
    'enableBlanketMode' => true,
    'blanketActionAllowlist' => [
        'freeform/submit',
    ],
];
bash
composer 
bash
php craft altcha/generate-hmac-key
twig
<form method="post">
	{{ csrfInput() }}
	{{ actionInput('users/save-user') }}

	{# … your fields … #}

	{{ craft.altcha.renderWidget() }}

	<button type="submit">Register</button>
</form>

freeform/submit
campaign/forms/*