gpt4 book ai didi

php - wordpress - 发表评论时调用函数

转载 作者:搜寻专家 更新时间:2023-10-31 21:44:43 24 4
gpt4 key购买 nike

每当有人发表评论时,我都想在 php 中采取一些行动。我怎样才能为此设置一个钩子(Hook)?我假设它会进入 functions.php...

编辑 - 这是我更新的代码:

add_action('comment_post', 'comment_posted');


function comment_posted() {
$MyClass = new MyClass(); //I do this in other functions and don't have any blank screen problems
$test = "";
$MyClass->doSomething($test);
}

最佳答案

参见:http://codex.wordpress.org/Function_Reference/wp_new_comment

Calls 'comment_post' action with comment ID and whether comment is approved by WordPress.

然后您应该能够从您的 functions.php 中调用 add_action('comment_post', 'my_func');

关于php - wordpress - 发表评论时调用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5759882/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com