wordpress - 发布评论时调用函数

时间:2011-04-22 20:46:53

标签: php wordpress comments

每当有人发表评论时,我想在php中采取一些行动。我该怎么设置一个钩子呢?我假设它会进入functions.php ...

编辑 - 这是我的udpated代码:

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); 
    }

1 个答案:

答案 0 :(得分:1)

请参阅:http://codex.wordpress.org/Function_Reference/wp_new_comment

  

使用评论ID调用'comment_post'操作,以及评论是否已被WordPress批准。

您应该可以在您的functions.php。

中调用add_action('comment_post', 'my_func');