Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
billythekid committed Apr 11, 2016
1 parent e08fa53 commit f658166
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions recaptchaguest/RecaptchaGuestPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public function getName()
*/
public function getVersion()
{
return '0.0.1';
return '0.0.2';
}

/**
* @return string
*/
public function getSchemaVersion()
{
return '0.0.1';
return '0.0.2';
}

/**
Expand Down Expand Up @@ -86,18 +86,20 @@ public function init()
craft()->on('guestEntries.beforeSave', function (GuestEntriesEvent $event)
{
$entryModel = $event->params['entry'];
$recaptchaPlugin = craft()->plugins->getPlugin('recaptcha', false);

$captcha = craft()->request->getPost('g-recaptcha-response');
$verified = craft()->recaptcha_verify->verify($captcha);

if (!$verified)
if ( $recaptchaPlugin->isInstalled && $recaptchaPlugin->isEnabled)
{
//Uh oh...its a robot. Don't process this form!
$entryModel->addError('recaptcha', "There was a problem with the captcha.");
$event->isValid = false;
$captcha = craft()->request->getPost('g-recaptcha-response');
$verified = craft()->recaptcha_verify->verify($captcha);

if (!$verified)
{
//Uh oh...its a robot. Don't process this form!
$entryModel->addError('recaptcha', "There was a problem with the captcha.");
$event->isValid = false;
}
}


});
}
}

0 comments on commit f658166

Please sign in to comment.