doukan3504 2011-10-04 19:57
浏览 42
已采纳

Magento:注册客户也需要双重选择通讯

I have successfully setup the newsletter subscription for guests, so that if a guest signs up for the newsletter, 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?

  • 写回答

1条回答 默认 最新

  • dongwuwei0718 2011-10-04 20:12
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图