开发者

Magento: Newsletter double opt-in also needed for registered customers

I have successfully setup the newsletter subscription for guests, so that if a guest signs up for the newsletter开发者_如何学C, he gets the newsletter confirmation request email where he has to click the confirmation link. This "double opt-in" is needed for every newsletter-signup by law here in Germany.

The problem is with customers who are already registered: they can subscribe in their account to the newsletter but here there is no double opt-in. So after checking subscribe they get immediately subscribed to the newsletter without getting the confirmation request email.

I have found only old tutorials on how to change this to double opt-in for registered customers, but these tutorials do not work anymore with my current version of Magento (1.5).

So how do I change the function "subscribe" in app/code/core/Mage/Newsletter/Model/Subscriber.php to get this behavior?


If they have the same code (or at least very similar) as 1.6, then you should be able to comment out what is line 291 for me in public function subscribe($email):

$isOwnSubscribes = ($customerSession->isLoggedIn() && $ownerId == $customerSession->getId());

And it will mark the subscription as "not active" rather than immediately "subscribed". For reference, here's that chunk of code:

// if user subscribes own login email - confirmation is not needed
$ownerId = Mage::getModel('customer/customer')
     ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
     ->loadByEmail($email)
     ->getId();
 $isOwnSubscribes = ($customerSession->isLoggedIn() && $ownerId == $customerSession->getId());
 if ($isOwnSubscribes == true){
      $this->setStatus(self::STATUS_SUBSCRIBED);
 }
 else {
      $this->setStatus(self::STATUS_NOT_ACTIVE);
 }

Right up above that it's setting the $isOwnSubscribes flag to false, so this will just let it remain false. You could also comment out the $ownerId loading as well, as it's only used in the part to check if the user is subscribing their own email.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜