duanhe4155 2013-02-12 01:40
浏览 50

Magento客户激活模块破解了客户群

I installed a free extension that requires admin approval before a customer can log in. I am hacking it to try to get it to allow all customer groups except for one. I think the following is the function that I would edit, but when I do a test registration the test cookie does not show up in my console. Any ideas?

/**
     * Flag new accounts as such
     *
     * @param Varien_Event_Observer $observer
     */
    public function customerSaveBefore($observer)
    {
        $customer = $observer->getEvent()->getCustomer();

        $storeId = Mage::helper('customeractivation')->getCustomerStoreId($customer);
        $session = Mage::getSingleton('customer/session'); // var $session Mage_Customer_Model_Session
$customer_info = $session->getCustomer(); // var $customer Mage_Customer_Model_Customer
$userinfo = $customer_info->_origData; // fetch users info

// get user's customer group id number
$customer_group = $userinfo['group_id']; 
setcookie("Group", "yes");

        if (Mage::getStoreConfig(self::XML_PATH_MODULE_DISABLED, $storeId))
        {
            return;
        }

        if (!$customer->getId())
        {
            $defaultStatus = Mage::getStoreConfig(self::XML_PATH_DEFAULT_STATUS, $storeId);
            $customer->setCustomerActivated($defaultStatus);
            $customer->setCustomerActivationNewAccount(true);
        }
    }

My code is the:

$customer_info = $session->getCustomer(); // var $customer Mage_Customer_Model_Customer
$userinfo = $customer_info->_origData; // fetch users info

// get user's customer group id number
$customer_group = $userinfo['group_id']; 
setcookie("Group", "yes");
  • 写回答

2条回答 默认 最新

  • doulan9287 2013-02-12 08:22
    关注

    First: Please don't try to hack the module. Better create your own module rewriting the classes of the original module, so you'll still be able to update the original one.

    Second: Are you sure that part of code is executed? What happens if you enter a die() in it?

    Third: You can see a list of all triggered event by implementing the firegento-debug module, so you could check if that event is really fired and the observer called.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看