Wordpress Coding a custom action hook

隐身守侯 提交于 2019-12-23 04:26:13

问题


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.


回答1:


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' )

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



来源:https://stackoverflow.com/questions/28149697/wordpress-coding-a-custom-action-hook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!