Reputation: 135
I have the following issue with the default newsletter system in Magento: if a registered CUSTOMER who has already signed up for the newsletter tries to sign up again, he gets an error which says that he is already subscribed, which is normal. However, if a GUEST (NOT LOGGED IN) customer is already subscribed to the newsletter and he tries to sign up again it works, he receives the newsletter confirmation email and he can confirm his subscription whithout getting any errors, which is not ok. Is there any way to check if a GUEST (NOT LOGGED IN) customer is already subscribed, so that he can get an error when he tries to sign up again?
Thanks,
Alex
Upvotes: 3
Views: 6847
Reputation: 17656
Take a look @
Class : Mage_Newsletter_SubscriberController
Path : /app/code/core/Mage/Newsletter/controllers/SubscriberController.php
Table : newsletter_subscriber
Assuming that you create a custom module that overriding Mage_Newsletter_SubscriberController
Around line # 63 Add (Above $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
)
$emailExist = Mage::getModel('newsletter/subscriber')->load($email, 'subscriber_email');
if ($emailExist->getId()) {
Mage::throwException($this->__('This email address is already exist.'));
}
To overriding Newsletter controller in frontend
<?xml version="1.0" encoding="iso-8859-1"?>
<config>
<frontend>
<routers>
<newsletter>
<args>
<modules>
<My_Newsletter before="Mage_Newsletter_SubscriberController">My_Newsletter</My_Newsletter>
</modules>
</args>
</newsletter>
</routers>
</frontend>
</config>
Upvotes: 5