Archive for January 19th, 2005

more for the ultimate comment idea

in addtion to the previous post, i wrote a piece of code where you can add above

$wpdb->query("INSERT INTO $tablecomments

in your wp-comments-post.php to have it delete unapproved comments that’s ___ days old

//// Auto delete unapprove comments if the comment is ___ days old $how_old_comment = 10; // 10 days $current_time = time(); $comment_date = $wpdb->get_var("SELECT comment_date FROM $tablecomments WHERE comment_approved='0'"); $comment_time = mysql2date('U', $comment_date) + $how_old_comment * 24 * 3600; if($comment_time < $current_time) { // delete the comment $wpdb->query("DELETE FROM $tablecomments WHERE comment_approved='0' AND comment_date='$comment_date'"); } //// End delete unapprove comments if the comment is ___ days old
i haven’t thoroughly tested this code. if you have problems, let me know.

also here’s a script you can run to get rid of blank and/or invalid email addresses in your comments table. get the code here, paste it to a text file. modify the $default_email variable and name it dodos_update_blank_emails.php. then upload the script to your wp root directory and run it. do it at your own risk. i have tested it on my own site and it worked for me.