当有人购买课程或订单成功完成时,我需要立即执行一个函数。我试图执行的函数实际上称为API。我看不出LearnPress有一个合适的钩子。
当我使用“user_register”(当有人注册这个钩子火)钩子时,它工作得很好,但是当我使用LearnPress给出的这个"learn_press_confirm_order“钩子时,它就不起作用了。
你们知不知道有什么合适的方法可以让我跟随并实现这一点。谢谢您抽时间见我
发布于 2020-04-03 03:26:38
首先,您的Lime密钥应该被视为一个密码-不要在网上共享它!立即转到您的LimeLM帐户,选择“设置”,并选择“生成新键”。我会等:)
显然,您的代码没有什么问题,所以我会像这样调试它:
add_action之后立即放了一个die('setup');。我们希望确保这个文件实际上正在被调用。如果是的话,删除die.wp-content/plugins/learnpress并键入(在Linux或其他什么地方)grep -R "learn_press_confirm_order" .
这将显示引用此操作的所有文件。只有一个:
./templates/order/confirm.php:transaction_method,$order->get_id( );?>
所以,拔出一个编辑器并编辑wp-content/plugins/learnpress/templates/order/confirm.php。您需要确定:
1. Whether the file is being run at all when you order. (Use `die` right at the top, or `error_log` if you can see your webserver/php log files.)
2. I'm fairly certain at this point you will have found the error, but there's a chance for some reason you're getting to this page, but the action isn't being called. So you might need to work out the exact flow of control on this `confirm.php` page. Again, `die` or `error_log`.
您可以对learnpress的代码进行实时更改,以帮助您调试它。大多数人害怕钻研别人的代码,但这是开源的强大力量。您可以在完成后重新安装学习新闻。
期待听到它的进展情况:)
https://stackoverflow.com/questions/60994301
复制相似问题