# I’ve been getting more comment spam that’s not automatically nixed by Akismet. Under Settings > Discussion you can add terms to a blacklist so that comments are automatically placed in the bin but I wanted to go one step further.
I found a code snippet described as automatically deleting spam comments but it actually prevents them from being submitted in the first place using
wp_die to kill the process on detection of specified terms.
It didn’t seem to work properly throwing “empty needle” errors when the found term was not the first in the list. Not only that but to edit the list of prohibited terms you would have to edit the code itself.
So I reworked it, fixed the empty needle errors by changing the detection method and created a simple plugin which lets you specify banned terms via a settings page in wp-admin.
When a banned term is found the comment is prevented from being submitted and
wp_die kicks in displaying a reason and the prohibited term:
I’ll see how it goes and will be adding more items as I come across them, but let me know if you have any problems submitting comments and what term is specified.
You can check out the plugin on GitHub.