1. Go to this page and download the library: Download craftcms/contact-form 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/ */
use craft\contactform\models\Submission;
use yii\base\Event;
// ...
Event::on(Submission::class, Submission::EVENT_AFTER_VALIDATE, function(Event $e) {
/** @var Submission $submission */
$submission = $e->sender;
// Make sure that `message[Phone]` was filled in
if (empty($submission->message['Phone'])) {
// Add the error
// (This will be accessible via `message.getErrors('message.phone')` in the template.)
$submission->addError('message.phone', 'A phone number is
use craft\contactform\events\SendEvent;
use craft\contactform\Mailer;
use yii\base\Event;
// ...
Event::on(Mailer::class, Mailer::EVENT_BEFORE_SEND, function(SendEvent $e) {
$isSpam = // custom spam detection logic...
if ($isSpam) {
$e->isSpam = true;
}
});
use craft\contactform\events\SendEvent;
use craft\contactform\Mailer;
use yii\base\Event;
// ...
Event::on(Mailer::class, Mailer::EVENT_AFTER_SEND, function(SendEvent $e) {
// custom logic...
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.