PHP code example of boundstate / craft-contactform
1. Go to this page and download the library: Download boundstate/craft-contactform 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/ */
class SomePlugin extends BasePlugin
{
// ...
public function init()
{
craft()->on('contactForm.beforeSend', function(ContactFormEvent $event) {
$message = $event->params['message'];
// ...
if ($isVulgar)
{
// Setting $isValid to false will cause a validation error
// and prevent the email from being sent
$message->addError('message', 'Do you kiss your mother with those lips?');
$event->isValid = false;
}
if ($isSpam)
{
// Setting $fakeIt to true will make things look as if the email was sent,
// but really it wasn't
$event->fakeIt = true;
}
});
}
}
class SomePlugin extends BasePlugin
{
// ...
public function init()
{
craft()->on('contactForm.beforeMessageCompile', function(ContactFormMessageEvent $event) {
$message = $event->params['message'];
$htmlMessage = $event->params['htmlMessage'];
$messageFields = $event->params['messageFields'];
// ...
$event->params['message'] = 'Make email great again! - '.$message;
$event->params['htmlMessage'] = '<p>Make email great again! - '.$message.'</p>';
});
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.