Magento 向特定电子邮件地址域发送新用户电子邮件确认

Magento 向特定电子邮件地址域发送新用户电子邮件确认,magento,magento-1.7,Magento,Magento 1.7,在我的Magento安装中,我禁用了“需要电子邮件确认”功能,因为我不需要所有用户都使用它。不过,我希望特定域“foo.com”的用户能够实际收到此电子邮件确认 一旦他们通过电子邮件链接确认了他们的电子邮件地址,我就会将他们添加到特定的组中 有谁能告诉我从哪里开始修改Magento吗?多谢各位 您可以扩展或覆盖 app/code/core/Mage/Customer/controllers/AccountController.php public function createPostActi

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

一旦他们通过电子邮件链接确认了他们的电子邮件地址,我就会将他们添加到特定的组中


有谁能告诉我从哪里开始修改Magento吗?多谢各位

您可以扩展或覆盖

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;

        }
    }
}
app/code/core/Mage/Customer/controllers/AccountController.php
公共函数createPostAction()
{
if(true==$validationResult){
$customer->save();
//请在此处输入您的自定义代码,以匹配您要确认的域。
$patterns=array('@foo.com','@boo.com','@bar.com');
$patterns_platten=内爆(“|”,$patterns);
if(preg_match('/'.$patterns_.'/i',$customer->getEmail(),$matches))
{  
$customer->setIsConfirmationRequired(true);
}
如果($customer->isConfirmationRequired()){
$customer->sendNewAccountEmail('confirmation',$this->\u getSession()->getBeforeAuthUrl());
$this->\u getSession()->addSuccess($this->\uuuu('需要帐户确认。请检查您的电子邮件中的确认链接。若要重新发送确认电子邮件,请',
Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())
));
$this->_redirectSuccess(Mage::getUrl('*/*/index',数组(''u secure'=>true));
返回;
}
否则{
$this->_getSession()->setCustomeraLoggedin($customer);
$url=$this->\u欢迎客户($customer);
$this->\u重定向成功($url);
返回;
}
}
}
所以你可以用两种方法来做

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

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


谢谢

供参考。在版本1.7.2中,您需要注意以下几点:1。更改:$customer->setIsConfirmationRequired(true);至$customer->setConfirmation(空);2.之后,您需要保存它:$customer->save();