Wanted: Akismet Warning Plugin
Published 17 years, 10 months pastOkay, with my WordPress install mostly stabilized (I even fixed the archive paging!), I have a LazyWeb request for all you WP hackers. What I want is very simple: a WP 2.x plugin that notifies a commenter when their comment has been condemned to the Akismet queue. I’ve had a few legitimate comments suffer that fate, and I imagine there have been more I never saw, so it’s something I’d really like to have (and something I think other people would also find useful).
At the most basic level, all I really want is for the plugin to die()
with a message telling the commenter that their comment has been Akismetted and that they should contact the site administrator about it if they’re legitimate. If instead of dying it gave that message upon returning them to the post on which they commented, the way “Your message is awaiting moderation” works, that would be extra-cool. Either way, it obviously only fires if the comment has been marked spam
.
I’m guessing this is a pretty simple plugin to write. I did attempt to write it myself, but was spectacularly unsuccessful in the attempt. The really frustrating part is that I think I got close to making it work, but, in the end, failed badly. Then I asked for plugin help on IRC, but nobody noticed. So I’m throwing the request out to the audience here to see what y’all can do. Thanks to anyone who can help!
Update 5 Feb 07: Mark Jaquith has come through with Antispam Collateral Condolences, a plugin that does exactly what I requested. It can put up the warning either as a JavaScript alert box, or a message embedded in the page upon returning them to the post on which they commented. Totally, completely awesome. You rock, Mark!
Comments (12)
Well, if you don’t mind hacking the Akismet Plugin itself, there is a function
akismet_auto_check_comment()
which preprocesses the comment.In line
204
through214
, the spam comment gets put in the spam queue. In line212
you could add a redirect yourself which notifies the user of bad things happening.Hope that helps. I doubt you could make a plugin that notifies the user without hacking the Akismet Plugin itself. Akismet adds itself as the first action in the comment preprocessing queue. If you could put a custom action before that, you’d probably be best off by storing the comment in a session, letting Akismet do it’s job and on the next page check whether the comment has been actually posted or not. Akismet doesn’t exactly provide any API hooks from what I can see.
I’d be a tiny bit worried that you’d effectively be sending a confirmation email to the spammers as well. Wouldn’t you be waving a big flag saying “Spam Me!!!”
With the amount of comment spam these days, I check my moderation queues less and less. Comment spam really increases the cost of blog ownership, and if you don’t start to ignore it, you’ll spend your life in moderation hell!
Not sure how it works with the WordPress plug-in specifically, but I use Akismet on my home-grown blog and it was simply a matter of adding what I wanted to the
exit()
line in the PHP code. I imagine you could do the same?Mine just looks like this:
if($akismet->isSpam()) {
// Save the suspicious comment in the spam table
/*** Insert query goes here ***/
// Delete the buffer
ob_end_clean();
exit("Akismet thinks your comment is spam. E-mail me (amber at tangerinecs dot com) if that's not the case.");
}
I’m interested in the same plugin/hack. If you find something that works, please let me know.
It does help, Alexander—thanks! I’m wondering if a redirect or a
die
at that point is a good idea, though. It would prevent the next few lines from executing, and those look like cleanup actions. I think. Then again, I’m confused by lines 213-214, which invoke adie
under certain conditions, only I don’t know how likely it is to see those conditions.If the
die
on 213 isn’t often triggered, then I’d probably drop a conditional right after line 216 (akismet_delete_old();
) in order to make this happen. I think a plain olddie
would be good enough for me at the moment, considering that redirects are kind of dark-gray magic to me. (I get the general principle, but the specifics of their handling in WP bedevil me.)Gerard, I don’t think this would be that big a flag, since I’m not sending anyone any e-mail. I’m just throwing what is, in effect, an error page back at the web browser. I suppose that I could eventually get fancy and return an HTTP error code and page, maybe a 417.
Sounds like a generally good idea, Amber, except the way the Akismet WP plugin is written, there are a few
exit
s scattered about, and identifying just the right one is a bit tricky for me. I think I’ll probably do something based on Alexander’s suggestion.Try this!
That was actually the sole reason that I put that hook (
comment_post_redirect
) in there… just never got around to writing the plugin to use it.Default notification is JS
alert()
because that’ll work most generally, but I included an alternative notification method that you can use if your theme has thecomment_form
hook.Awesome, Mark! Thank you! I just tested it with some choice bits from my Akismet queue and it works great. I went with the JS popup method, since it’s the most obvious. I bow down before your PHP and WP sagacity.
Just a quick test here to see if I get the warning on a legitimate comment.
…and another test of the plugin.
Nice Mark, I didn’t think this was possible. Clean solution, I like it.
Pingback ::
XiAP Design: Web & Graphic design | WordPress & MacOSX Themes » Antispam Collateral Condolences
[…] is an interesting plugin I found by chance in reading Eric Meyer’s blog. So what does it do? This plugin will notify commenters when their comments are […]
Pingback ::
Todays Spammers - Page 2 - Net Builders
[…] are too many spam comments to justify the time it takes to review the spam bin. I came across a solution which is to add a hack to the exit() line in the PHP code. This would notify the commenter that […]