0

在我的 Magento 安装中,我禁用了“需要电子邮件确认”功能,因为我不需要所有用户。但是,我希望特定域“foo.com”的用户实际收到此电子邮件确认。

一旦他们使用电子邮件链接确认他们的电子邮件地址,我想将他们添加到特定组。

谁能告诉我应该从哪里开始进行这种 Magento 修改?非常感谢你!

4

1 回答 1

1

您可以扩展或覆盖

app/code/core/Mage/Customer/controllers/AccountController.php

public function createPostAction()
{
    if (true === $validationResult) {
        $customer->save();

        // Do your custom Code here to match the domains you want to make Confirmation Required for them.
        $patterns = array('@foo.com','@boo.com','@bar.com');
        $patterns_flattened = implode('|', $patterns);
        if ( preg_match('/'. $patterns_flattened .'/i', $customer->getEmail(), $matches) )
        {  
            $customer->setIsConfirmationRequired(true);
        }

       if ($customer->isConfirmationRequired()) {
            $customer->sendNewAccountEmail('confirmation', $this->_getSession()->getBeforeAuthUrl());
            $this->_getSession()->addSuccess($this->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.',
                Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())
           ));
            $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure'=>true)));
            return;
        }
        else {
            $this->_getSession()->setCustomerAsLoggedIn($customer);
            $url = $this->_welcomeCustomer($customer);
            $this->_redirectSuccess($url);
            return;

        }
    }
}

所以你可以通过两种方式做到这一点

启用激活电子邮件并设置$customer->setIsConfirmationRequired(false);电子邮件是否与您要验证的域不匹配(推荐)

禁用激活电子邮件并设置$customer->setIsConfirmationRequired(true);电子邮件是否与您要验证的域匹配

谢谢

于 2012-09-09T00:00:46.660 回答