Hi there, I have created a small hack that will auto close your comments after 30 days.
// Auto Closing Comments. Comments Will Automatically Be Closed After A Month Old.
if($post->comment_status != 'closed') {
$current_time = time();
$post_time = the_time('U', false) + 2678400;
if($post_time < $current_time) {
$wpdb->query("UPDATE $tableposts SET comment_status = 'closed' WHERE ID = '$id' AND comment_status = 'open'");
}
}
// End Auto Closing Comments
Place the code in your index page right after start_wp();.
This is how it works. For everypost on the page it will check the post date and compare. If it is more than 1 month old, it will update the "commet_status" field of $tableposts to "closed".
It is a small scale, feel free to modify it and make it more efficient.
Anonymous
Unregistered
Posted 7 years ago #
Hi, I tried this code and it works:
$current_time = time();
$post_time = the_time('U', false) + 2678400;
if (('open' == $post->comment_status) && ($post_time < $current_time)) {
$wpdb->query("UPDATE $tableposts SET comment_status = 'closed' WHERE ID = '$id' AND comment_status = 'open'");
}
Anonymous
Unregistered
Posted 7 years ago #
Can someone clarify where this code needs to be inserted in index.php as my file does not contain the command start_wp();
I'm using 1.2.1
Anonymous
Unregistered
Posted 7 years ago #
I've just activated the plug in and got the following error message
Sorry, you need to enable sending referrers, for this feature to work.
?????
I also got this message earlier tonight trying to delete a very old post.
Anonymous
Unregistered
Posted 7 years ago #
That's sorted it. I had just changed to kerio because zonealarm free version kept bugging on me and just needed to untick a box.
thanks, AGAIN :-)