【发布时间】:2017-03-18 02:10:06
【问题描述】:
当我批量批准 cmets 时,它只会得到一个 comment_post_ID。
我需要得到所有的comment_post_ID。
这段代码:
add_action('transition_comment_status', 'my_approve_comment_callback', 10, 3);
function my_approve_comment_callback($new_status, $old_status, $comment) {
if ($old_status != $new_status && $new_status == 'approved') {
$my_file = fopen("/tmp/postidlist.txt", "w");
$comment_id_2 = get_comment($comment->comment_ID);
$comment_post_id = $comment_id_2->comment_post_ID;
fwrite($my_file, $comment_post_id);
fclose($my_file);
}
}
【问题讨论】:
标签: php wordpress file comments fopen