首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在购买课程/在LearnPress中完成订单后执行自定义功能?

在购买课程/在LearnPress中完成订单后执行自定义功能?
EN

Stack Overflow用户
提问于 2020-04-02 14:44:54
回答 1查看 1.1K关注 0票数 0

当有人购买课程或订单成功完成时,我需要立即执行一个函数。我试图执行的函数实际上称为API。我看不出LearnPress有一个合适的钩子。

当我使用“user_register”(当有人注册这个钩子火)钩子时,它工作得很好,但是当我使用LearnPress给出的这个"learn_press_confirm_order“钩子时,它就不起作用了。

你们知不知道有什么合适的方法可以让我跟随并实现这一点。谢谢您抽时间见我

EN

回答 1

Stack Overflow用户

发布于 2020-04-03 03:26:38

首先,您的Lime密钥应该被视为一个密码-不要在网上共享它!立即转到您的LimeLM帐户,选择“设置”,并选择“生成新键”。我会等:)

显然,您的代码没有什么问题,所以我会像这样调试它:

  1. add_action之后立即放了一个die('setup');。我们希望确保这个文件实际上正在被调用。如果是的话,删除die.
  2. Wordpress和LearnPress是很棒的,因为您已经获得了源代码。转到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。您需要确定:

代码语言:javascript
复制
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的代码进行实时更改,以帮助您调试它。大多数人害怕钻研别人的代码,但这是开源的强大力量。您可以在完成后重新安装学习新闻。

期待听到它的进展情况:)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60994301

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档