Beantin webbkommunikation

Beantin Beta Blog

Experiments, investigations, and tests of web things
August 26, 2010

How to stop WordPress comment spam when using Disqus

I’ve had Disqus installed since day one on this blog. No spam whatsoever in Disqus. Lovely and Quiet. To my surprise, comments posted via bots and scripts kept on coming in.

Ok, they were never visible on the site – but I kept receiving email notifications and needed to mark them all as spam from within WordPress admin. I’d presumed that installing Disqus would completely disable the default comment system within WordPress.

But it doesn’t. It leaves the original system intact, including the possibility for bots and scripts to inject comments directly into your WordPress comment system – note not disqus, but WordPress.

No solution?

I’d asked around a few times and searched a fair bit too, but nothing at all came up in relation to Disqus and comment spam – apart from a people recommending using Disqus to prevent spam, people having spam problems with Disqus, and the odd person with (probably) the same problem.


Then I found the combating comment spam page on and read that the ultimate way of disabling commenting is to delete wp-comments-post.php from the base directory of your WordPress installation.

You will, of course, need to check and (re)delete the file again every time you upgrade.

The elegant solution

A little later, I found a more elegant solution. You can make use of a wordpress action hook in the functions.php file of your theme.

add_action('pre_comment_on_post', 'block_wp_comments');

function block_wp_comments() {
wp_die( __('Sorry, comments are closed for this item.') );

Much tidier than deleting a file. You will of course have to make sure this function is in place should you change or upgrade theme.

Related Posts Plugin for WordPress, Blogger...


Filed under Configuration, Wordpress.

Tags: , ,

Theme Beantin created by James Royal-Lawson. Privacy Policy