如果包含特定字符串,如何自动删除注释?
我尝试过这个,但没有成功:
add_action( \'transition_comment_status\', \'my_approve_comment_callback\', 10, 3 );
function my_approve_comment_callback( $new_status, $old_status, $comment ) {
if (strpos($comment->comment_content, \'dog\') !== false) {
wp_delete_comment( $comment->comment_ID, true );
}
}
我还尝试了:wp_list_comments(\'callback=better_comment\');
function better_comment($comment, $args, $depth) {
if (strpos($comment->comment_content, \'dog\') !== false) {
wp_delete_comment( $comment->comment_ID, true );
}
}
没什么用=(