Permalink
Browse files

Move recaptcha and mailchimp integrations to event handlers

  • Loading branch information...
themightychris committed Jan 4, 2016
1 parent 29d1988 commit da7f74f2b4682567c9e2ccd0ff44107b85182417
@@ -0,0 +1,9 @@
<?php
if ($recaptcha = \RemoteSystems\ReCaptcha::getInstance()) {
$recaptchaResponse = $recaptcha->verify($_EVENT['requestData']['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
if (!$recaptchaResponse->isSuccess()) {
$_EVENT['additionalErrors']['ReCaptcha'] = 'Please prove that you aren\'t a spam robot by completing the reCAPTCHA';
}
}
@@ -0,0 +1,16 @@
<?php
// add new user to a MailChimp list (see http://forum.laddr.us/t/mailchimp-integration/26)
#\RemoteSystems\MailChimp::call('lists/subscribe', [
# 'id' => 'YOUR_LIST_ID_HERE',
# 'email' => [
# 'email' => $_EVENT['User']->Email
# ],
# 'merge_vars' => [
# 'FNAME' => $_EVENT['User']->FirstName,
# 'LNAME' => $_EVENT['User']->LastName
# ],
# 'double_optin' => false,
# 'replace_interests' => false,
# 'send_welcome' => false
#]);
@@ -1,32 +0,0 @@
<?php
namespace Emergence\People;
#RegistrationRequestHandler::$onRegisterComplete = function(User $User, array $requestData) {
# // this hook is run after a new user acconut has been registered (the user is waiting though so keep things moving!)
#
# // add new user to a MailChimp list (see http://forum.laddr.io/t/mailchimp-integration/26)
# \RemoteSystems\MailChimp::call('lists/subscribe', [
# 'id' => 'YOUR_LIST_ID_HERE',
# 'email' => [
# 'email' => $User->Email
# ],
# 'merge_vars' => [
# 'FNAME' => $User->FirstName,
# 'LNAME' => $User->LastName
# ],
# 'double_optin' => false,
# 'replace_interests' => false,
# 'send_welcome' => false
# ]);
#};
RegistrationRequestHandler::$applyRegistrationData = function(User $User, array $requestData, array &$additionalErrors) {
if ($recaptcha = \RemoteSystems\ReCaptcha::getInstance()) {
$recaptchaResponse = $recaptcha->verify($requestData['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
if (!$recaptchaResponse->isSuccess()) {
$additionalErrors['ReCaptcha'] = 'Please prove that you aren\'t a spam robot by completing the reCAPTCHA';
}
}
};

0 comments on commit da7f74f

Please sign in to comment.