Wordpress 编写自定义操作挂钩 [英] Wordpress Coding a custom action hook

查看:70
本文介绍了Wordpress 编写自定义操作挂钩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个自定义 wordpress 插件来管理我的会员类型.为了处理付款,我想要有 2 个自定义操作挂钩,一个用于 payment success,另一个用于 payment failure.如果可能的话,我希望这些钩子适用于所有主题.

I am trying to develop a custom wordpress plugin to manage my membership types. To handle payments I want to have 2 custom action hooks one for payment success and one for payment failure. And if possible I want these hooks to work in all the themes.

无法想出合适的解决方案.有谁知道在哪里放置会员类型的模板.

Could not come up with a proper solution. Does anybody knows where to place the templates for membership types.

推荐答案

你可以使用下面的代码来执行你自己的动作钩子:

You can use the following code to execute your own action hook:

do_action( 'payment_success' )

然后你可以钩住"这个钩子:

Then you can 'hook onto' this hook with:

add_action( 'payment_success', 'your_function' )

由于主题的functions.php文件是在所有插件加载后加载的,所以你的hook在所有主题中都可用.

Since the theme's functions.php file is loaded after all the plugins are loaded, your hook will be available in all themes.

这篇关于Wordpress 编写自定义操作挂钩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆