I use WordPress on my personal blog. I've had a bit of an ongoing battle with spammers, although fortunately not to the extent larger sites have. There are several plugins that can help, but for my relatively low traffic, I felt just a simple fix was all I needed. I won't be surprised if I'm proven wrong though, as I was once already.
Spammers generally to post to WordPress sites by directly calling the wp-comments-post.php script. One simple way to limit their ability to do this, while still leaving comments open is to add an extra field to the wp-comments.php form that is echekd for valid data by wp-comments-post.php. I've implemented the idea on my own site by requiring posters to enter the first word of the post title in an extra form field I've entered.
The following patches apply to WordPress v1.2.2, and enable the validation code. They also include the regonly feature below, so if you use these patches, you don't need the first tow in the next secion.
- updated 2005-02-06
The comment_status field in wp_posts table is set to enum('open', 'closed', 'registered_only'), but as far as I could tell, 'registered_only' didn't do anything. At least it didn't do what I expected when I set the comment_status to that value by editing the database directly. I had incorrectly assumed that it meant only registered users could post comments on against the story.
The following patches, which apply to WordPress v1.2.2, change four files to enable registered only commenting:
- updated 2004-12-14
Comments and bug reports are welcome. I've tested the combinations I can think of, but others may find some I didn't consider. The tests of wp-comments-post.php were done with a simple HTML form that tried to post directly to the script without going through WordPress.
All patches are released under the same license as the application being patched.
Copyright © 2004,2005 - Al Payne