谢谢大家的帮助。
这是我的最终解决方案:这是一个PHP片段,我将其粘贴到wp cron作业插件中。
add_action( \'wp_enqueue_scripts\', \'wp_privacy_anonymize_comments\' );
function wp_privacy_anonymize_comments() {
$expiry_date = date("Y-m-d", strtotime("-1 years"));
$args = array(
// args here
);
// The Query
$comments_query = new WP_Comment_Query;
$meta_values = $comments_query->query( $args );
foreach($meta_values as $meta_value) :
$current_comment_ID = $meta_value->comment_ID;
$current_comment_date = $meta_value->comment_date;
if ($current_comment_date < $expiry_date) {
//Override Userdata #anonymer-Bär
$update_comment = array(
\'comment_ID\' => $current_comment_ID,
\'comment_author\'=> \'Anonym \' . $current_comment_ID,
\'comment_author_email\' => \'[email protected]\',
\'comment_author_url\' => \'\'
);
wp_update_comment($update_comment);
}
endforeach;
}
谢谢大家:)你好,凯西