dtlhy0771 2016-11-28 15:09
浏览 47
已采纳

了解WHMCS挂钩优先级

I'm working on a module for WHMCS that needs to execute a few functions after the daily cron job. This isn't too hard to do, but I'm having some issues understanding hook priorities, since the functions need to be executed in a specific order.

I've looked online, but haven't found a definitive answer yet, and the WHMCS documentation is severely lacking in this aspect.

I'm looking for the following information:

  • Are hook actions executed by ascending or descending priority?
  • Are duplicate priorities for the same hook allowed?

Thanks!

  • 写回答

1条回答 默认 最新

  • dongzan1970 2016-12-01 10:40
    关注
    • Hooks are executed ascending. 1 before 2 before 3, and so on.
    • Duplicate priorities are supported. Hooks are then called in the order they are registered.

    I have seen some older reports that duplicate priorities override each other, but I tested in whmcs version 7.0 and verified that at least this code is executed as expected:

    <?php
    
    add_hook('ClientAreaPage', 1, function(){
       echo "First hook call";
    });
    
    add_hook('ClientAreaPage', 1, function(){
       echo "Second hook call";
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备