Php Prestashop HookActionCustomerAccountAddd不';我在行政区没有动火

Php Prestashop HookActionCustomerAccountAddd不';我在行政区没有动火,php,hook,prestashop-1.6,Php,Hook,Prestashop 1.6,我想在用户注册prestashop后向API发送一些ata 它在前台工作得很好,但在后台却没有启动活动 有什么想法吗?在前台,当客户注册时,它会执行钩子操作CustomerAccountAdd Hook::exec('actionCustomerAccountAdd', array( '_POST' => $_POST, 'newCustomer' => $customer

我想在用户注册prestashop后向API发送一些ata

它在前台工作得很好,但在后台却没有启动活动


有什么想法吗?

在前台,当客户注册时,它会执行钩子操作CustomerAccountAdd

Hook::exec('actionCustomerAccountAdd', array(
                            '_POST' => $_POST,
                            'newCustomer' => $customer
                        ));
在后台,它不会执行这样的钩子(或任何其他钩子)。但是您可以在override/controllers/admin/AdminCustomersController.php中创建覆盖

class AdminCustomersController extends AdminCustomersControllerCore
{
    public function processAdd()
    {
        $customer = parent::processAdd();
        if($customer === false)
             return false;

        // else do what you need here

        return $customer;
    }
}
另一种方法是,不使用钩子actionCustomerAccountAdd,您可以覆盖每次添加客户时都会执行的customer add函数,而不管该函数是在何处创建的(除非它添加到数据库中,并且不使用prestashop函数)。在override/classes/Customer.php中:

class Customer extends CustomerCore
{
    public function add($autodate = true, $null_values = true)
    {
        $res = parent::add($autodate, $null_values);
        if(!$res)
             return $res; // customer not added

        // do what you need. $this is the customer just added
    }
}

如果使用覆盖,请不要忘记删除文件cache/class_index.php

谢谢您的帮助:)@sadlyblue抱歉,您的答案并不完全正确。是的,您可以通过覆盖解决问题,但是这些操作和操作都有一个管理挂钩。另外,当添加对象时,您可以使用hook@drot,您是对的。不记得添加对象时“自动”执行的钩子。稍后我会更新我的答案。是的,只有在没有其他方法的情况下才应该使用覆盖。