[英]Magento Customer Activation module hack customer group
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.
我认为以下是我要编辑的功能,但是当我进行测试注册时,测试cookie不会显示在控制台中。 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");
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?
如果在其中输入die()会发生什么?
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. 第三:通过实现firegento-debug模块,您可以看到所有触发事件的列表,因此您可以检查该事件是否真正触发,并调用观察者。
Hi i was customizing the same extension. 嗨,我正在自定义相同的扩展名。
The thing is your are not getting the customer group. 问题是您没有得到客户群。
try this line for getting the customer group 尝试使用此行获取客户群
$customer = $observer->getEvent()->getCustomer(); $ customer = $ observer-> getEvent()-> getCustomer();
$groupId = $customer->getGroupId(); $ groupId = $ customer-> getGroupId();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.