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: , ,

116 Responses

  1. Anonymous Says:

    Great advice – this is becoming a plague across so many WordPress installations. I’ve had 1,600 spam comments on one blog alone in one week. Such a paint to deal with unless you know this advice.

  2. giannii Says:


    I’ve noticed this last night and we’re looking into the problem. We’ll be in touch soon.


  3. Disable WordPress Commenting System to prevent spam « Admins eHow Says:

    […] […]

  4. Anonymous Says:

    Thanks for the elegant solution to blocking wordpress comment spam. I also noticed continued wordpress spam, even though I was using disqus. Now, hopefully, it will stop.

  5. Med-i Says:

     It isn’t possible to block spam, with an analysis of keywords, or a stuf like this???

    In fact people have made scripts only to make automatic comments on their own blogs,
    but noobs used them so badly.

    It is those noob who spam, without correlation of their blog.

    And they are very stupid because google can show that is an automatic spamming, and  penalise them.

  6. nike mercurial Says:

    Very good like that make up the later can see such a lot to the article

  7. Christopher Jenkins Says:

    Thanks for this… got 30 just last night.  Will be nice to not have to clean them up anymore!

  8. Matt Smith Says:

    Thanks for this, I’ve been looking for a solution for this for a while.  Seems many people are unaware of this problem.


  9. Hawk_Wjunction_Noob Says:

    Thank you so much I love you!!!!!!!!!!!

  10. Loget_newbie Says:

    How do I test if this works??

  11. James Royal-Lawson Says:

    You should notice pretty quickly that the spam stops appearing directly in WordPress…

  12. didibus Says:

    I think the problem is related to disqus plugin itself. Disqus plugin saves comments made with Disqus to the WordPress database also. The problem is that the plugin does not mark those comments as spam or as deleted if they are within Disqus. I think it’s disqus responsibility to fix this. Disabling the wordpress commenting syste, is problematic, what about when you’ll want to go back to WordPress comments, or move to another comment system?

  13. James Royal-Lawson Says:

    This fix doesn’t stop Disqus from adding a copy of comments to your WordPress database. The comments this stops are those added directly via WordPress, not via Disqus.

  14. didibus Says:

    Ah I see, nice fix then, I will add it to my website. The disqus plugin still has the problem that it doesn’t update the wordpress database when you delete or mark a comment as spam. So if spam comes in through disqus, and one day you went back to wordpress comment system, you’d have a bunch of spam comments left in. Do you know of any fix for this?

  15. Terry Caliendo Says:

    I added your code above to my theme’s functions.php and I’m still getting the spam. To test, I turned off the Disqus plugin and submitted a comment.  I received the message in the code.  How can spammers still be getting into my comments?

  16. James Royal-Lawson Says:

     This doesn’t disable trackbacks, so you’ll still see spam coming in there. If you don’t want pingbacks and trackbacks enabled then you can turn them off in “discussion settings” in your WordPress admin.

  17. Terry Caliendo Says:

    Thanks for the reply, but I do already have the “Allow link notifications from other blogs (pingbacks and trackbacks)” unchecked. Any other ideas?

  18. James Royal-Lawson Says:

    Hmm. Don’t know to be honest Terry. I run this solution on a number of sites and the only spam that gets through is via pingbacks and trackbacks (as that option is turned on). This includes a few competitive keyword pages that attract a reasonable amount of spam.

  19. Terry Caliendo Says:

    I think I figured it out…  I had some older posts that I needed to manually update the trackbacks to be off.  So you were right… but the default setting in “discussion settings” didn’t update the older posts.
    — thanks again.

  20. Bunklung Says:

    Thanks for this! WordPress should do this automatically when another comment system is in place.

  21. Zosia Says:

    Great solution. I will do that on my polish site, many thanks!

  22. timverry Says:

    Thank you!! I’ve been trying to stop the flood of spam comments for a while now. Disqus comments have all been clean, but somehow the spammers were still submitting comments to the default WP comments even though I tried restricting those to only logged in users (and disabling registrations).

    Hopefully it works and I can get some semblance of sanity back! ;)

  23. TheScienceEnthusiast1130 Says:

    Nothing stops a hardcore SPAMMER!!!!

  24. Drambuie Says:

    thanks a lot dude!

  25. My Tech Team Says:

    Awesome! We just installed disqus at our site. I realize this post is several years old, but I’ll see if it works.

  26. vadakkus Says:

    Well, I added the code and seeing no result I then deleted wp-comments-post.php itself, but I am still heavily under attack by spam, several hundred every day! Oh yes, I removed trackbacks/pingbacks as well. Can I do anything else to stop this? I am at my wits end!

  27. James Royal-Lawson Says:

    is the spam in Disqus or in WordPress?

    If you’ve removed wp-comments-post and disabled trackbacks/pingbacks then there’s little left in WordPress.

    Perhaps you could try a plugin such as “Disable Comments”, although I’ve not tested that in combination with Disqus, so make sure you backup your site and database before testing – or test on a “sandbox”/test installation.

  28. vadakkus Says:

    The spam is in WordPress, which baffles me since I have removed wp-comments-post altogether. I think I should remove Disqus as well. The number of comments have now dropped though, but I still get around 8-10 per day. Can live with that, better than a 100! :)

  29. James Royal-Lawson Says:

    What you could do is make sure you’ve turned off pingbacks on all old posts in WordPress (and perhaps comments too) – i’ve written a quick guide here:

  30. Tasha Says:

    Does this still work? I would like to know before I try it. Reading the comments below, it doesn’t seem to work that well :( I am having a huge issue with spam coming into wordpress comments with Disqus installed! GRRRR

  31. James Royal-Lawson Says:

    Hi Tasha! Yes, what’s described in this post still does what it says… but depending on exactly what your problem is, you might want to look into additional measures, such as turning off pingbacks (including for all old posts).


  32. Tasha Says:

    I got some advice from a friend, she recommended a plugin I didn’t have. I
    downloaded Anti-Spam plugin and kept
    Askimet and Growmap Anti Spambot plugin that i already had. Haven’t had anymore spam
    comments getting into my WP comments while using Disqus! YAY! :D

  33. Piejs Says:


  34. TheScienceEnthusiast1130 Says:


  35. Jens P. Berget Says:

    I have been looking for this solution for a while. It seems that I am receiving a lot of spam comments every single day, and they’re not inside disqus but on wordpress (and I have disabled the comments). Hopefully this will help. Thank you!

  36. Alex Vojacek Says:

    Another cool solution if you’re using nginx is to stop access to wp-comments-post.php in nginx rules.

    location = /wp-comments-post.php {

    deny all;

  37. rurugby Says:

    I have over 800 spam messages, sounds like WordPress may need better spam protection in a simple way. It’s out of control.

  38. Mahesh Mohan Says:

    Disqus support team recommended this article.. but it’s not working for me… It’s showing a glimpse of WordPress comment system before Disqus starts loading.

  39. James Royal-Lawson Says:

    This solution is to stop comments and pings being inserted directly into your wordpress comment system via wp-comments-post.php. How your theme handles the displaying of comment systems lies elsewhere in your wordpress theme.

  40. Mahesh Mohan Says:

    Actually I tried many ways… I disabled comments like you have mentioned by deleting comment file and then added those codes to functions.php. But the wp comment system was showing as a glimpse…. also… I used to get spam commnets even after deleting wp file and even after making registration mandatory to leave comments.. not sure whats wrong….

  41. Johney Duke Says:

    I wanna thanks to a great extent for providing such informative and
    qualitative material therefore oftenbubblegum
    casting reviews

  42. Erio Says:

    I got here because i need to find if disqus could prevent spam, and this article quite help. Thank you

  43. Mahesh Mohan Says:

    deleting wp-comment file or turn of registration for new comments or removing comment codes from theme or nothing helped me…

    Then I got a solution… but it may not be what you desire…

    I simply blacklisted the following characters using WP Discussion Settings.


    So all new comments received via WP Comments are automatically marked as spams. And like I said, it WONT stop bots but at least it’s not bothering me now.. so am happy that way.

  44. Albert einstien Says:

    If you
    should be opting for finest contents like me, just visit this blog site daily
    because it provides the feature contents, thanks.

  45. Albert einstien Says:
    content shows the power, I’m about to add this to my bookmarks.

  46. coolperson633 Says:

    Informative article, precisely what I wanted.
    More Info

  47. Albert einstien Says:

    The stuff
    written in the blogs have allured me!!!

  48. vacumecleaner Says:

    I don’t
    waste my free time that’s why I read the informative things when I got this
    blog I really enjoyed reading this.

  49. Albert einstien Says:

    dudes! Amazing stuff continues the good work.

  50. Albert einstien Says:

    This is an
    informative blog by which I have got that info which I really wanted to get.

  51. Mike tyson Says:

    The information in this blog is extremely useful for the
    replica watches

  52. Albert einstien Says:

    method of telling, and enjoyable article to acquire factual statements.

  53. thomas Says:

    direct online payday loanscom

    I really
    enjoy reading and also appreciate your work.

  54. thomas Says:

    Truly the
    best blog I never got such information before this thanks.

    how to lose man boobs

  55. Albert einstien Says:

    I knew
    this blog post was existed someplace. Thanks to post such articles. Will
    unquestionably be using it very soon.

    linden method

  56. Mike tyson Says:

    The information you have given in the blog really
    marvelous and more interesting.

  57. Albert einstien Says:

    It’s been
    good to see your blog when I always look for such type of blogs. It’s great
    to discover the post here.

    Height Increasing Shoes

  58. thomas Says:

    Your blogs and its stuff magnetize me to return again n
    quick weight loss

  59. albert mark Says:

    information!!! I’ll be enchanted to greatly help due to what I’ve learnt from
    phlebotomy certification

  60. albert mark Says:

    unbelievable blog. This blog will indisputably be definitely recommended to
    my friends as well.
    technician salary

  61. Albert einstien Says:

    shortness of breath anxiety
    I want to
    say thank to you people for this great and helpful info. Thanks!!!

  62. thomas Says:

    Maid Service Prices
    information you have given in the blog really marvelous and more interesting.

  63. thomas Says:

    I know
    this is quality based blogs along with other stuff.

    healthy diet plan

  64. thomas Says:

    Great blog
    post! I don’t understand how long it will require me to obtain through all of


  65. vacumecleaner Says:

    suppose I’ve selected an unbelievable and interesting blog.
    hajj 2014

  66. thomas Says:

    up guys your doing a really good job.

  67. Joseph Cauley Says:

    guys, quality information you have given!!!
    Braun electric shavers

  68. helyfell Says:

    The Info
    in the blog is out of this world, I so want to read more.

    after effects tutorial

  69. Albert einstien Says:

    Thank you
    so much for such a great blog.

    facebook likes

  70. Mona Ali Says:

    شركة تخزين عفش بالرياض
    شركة ترميمات بالرياض
    شركة دهانات بالرياض
    شركات تنظيف المنازل بجدة
    شركة كشف تسربات المياة بجدة
    شركة مكافحة حشرات في جدة
    شركة تنظيف خزانات بجدة
    شركات نقل عفش جدة
    شركات تنظيف منازل بجدة
    شركات رش المبيدات حشرية بجدة
    عزل بالرياض
    عزل اسطح الرياض
    عزل خزانات الرياض
    تنظيف خزانات بالرياض
    تصغير المعدة
    تكميم المعدة
    تدبيس المعدة
    جراح المرارة بالمنظار
    شركات مكافحة القوارض بالرياض
    شركة مكافحة حشرات بالرياض
    شركة رش مبيد بالرياض
    شركة عزل خزانات بالرياض
    شركة تخزين عفش بالرياض
    شركة تنظيف بيارات بالرياض
    شركة تخزين عفش بالمدينة المنورة
    نقل عفش بالمدينة المنورة
    غسيل خزانات بالمدينة المنورة
    نقل عفش جدة
    شركات مكافحة الحشرات في جدة
    شركة تنظيف بجدة
    شركات رش المبيدات الحشرية بجدة
    شركة مكافحة حشرات بالدمام
    شركات تنظيف المنازل بالدمام
    شركة تسليك مجاري بالدمام
    شركة المنارة لنقل العفشبالرياض
    نقل أثاث بالرياض

  71. Richard german Says:

    This is an informative blog by which I have got that
    info which I really wanted to get.
    lubbock pay day loan
    for students

  72. Carla Dillon Says:

    you I am glad about the encouragement! I love your site, you post
    effects tutorial

  73. Carla Dillon Says:

    contents are moving ahead with days persevere guys.
    effects tutorial

  74. unsit polek Says:

    can reject the info you have given in the blogs, this is actually a great
    royal dar al eiman

  75. hely fell Says:

    quality articles are here. This is good site with useful info.user guides

  76. Albert einstien Says:

    quality articles are here. This is good site with useful info.

  77. unsit polek Says:

    I have
    been dotty by reading your blog because it has a unique data.
    auto insurance rates

  78. rishan safar Says:

    enormous round of applause, continue the great work.

  79. Allen Underwood Says:

    Fantastic! Thank you so much. For those who don’t know how to do what was mentioned in the article…log into your WordPress admin, go to Appearance –> Editor. Then select the them you have active on the right side of the page, and click Them functions after that. Then paste in the code provided in the article. Thanks for sharing – I’m really hoping this fixes the problem.

  80. deny lost Says:

    Your way to enlighten everything on this blog is
    actually pleasant, everyone manage to efficiently be familiar with it, Thanks
    a great deal.
    cool cartilage

  81. Carla Dillon Says:

    You have
    to waste less time to search your obligatory matter on web, because these
    days the searching ways of search engines are nice. That’s why I found this
    article at this point.
    and depression treatment

  82. Paranoimia Says:

    Thanks for this. I’ve been searching for a solution to this issue for a while, and this is about all I’ve found. I shall give it a try on my site later and hope it works!

    I don’t get a lot of spam, but it’s been steadily increasing over the last few months. It’s gone from the odd spam comment every few weeks, to a couple every few days, and I suspect it will only get worse.

    This is clearly something the people at WordPress need to take action on soon. If you’re using a comment plugin, there shouldn’t be any external access to the built in comment system at all.

  83. john willim Says:
    just what a blog it is! This blog has provided the helpful data to us
    continue the good work.

  84. henry Says:

    buddy, you have done the fantastic job, your post is genuinely amazing.

    what affects car insurance premiums for teenagers

  85. henry Says:

    I think I have never seen such blogs ever before that
    has complete things with all details which I want. So kindly update this ever
    for us.
    insurance quotes comparison

  86. grady williams Says:

    Excellent blog here.
    It’s out-of-the-way quality writing. If truth be told I appreciate the people
    like you! Take care
    web 2.0 service

  87. grady williams Says:

    blogs! I love it really!! Would come back to visit soon, again Thanks.

    comprhensive insurance laws

  88. henry jon Says:

    It’s a classic great for me to go to this blog site, it
    offers helpful suggestions
    media infographic

  89. henry jon Says:

    Hi, thanks for your
    great information! Well, it really seems so great.
    buy backlinks

  90. Melvin Gregor Says:

    Having studied this
    I considered this post was very edifying. I appreciate you have put the nice
    efforts in this blog.
    best home
    security systems

  91. Raul Wint Says:

    This is one amongst
    my desired blogs; I have got enough knowledge through this.
    umrah package

  92. ALBERT LIET Says:

    I frequently don’t
    respond to the posts but I have been dotty of your blog, it has compelled me
    to do this.
    hajj package

  93. mark bill Says:

    I was
    seeking this convinced info for a long time. Thank you for offering such
    great information and good luck.

    life ins quotes

  94. Steve James Says:

    I know this is an old post, but I have recently installed disqus at my WP blog and the WP comments stopped instantly., Maybe they have upgraded the plugin to incorporate the above mentioned changes?/

  95. felyhely Says:

    Hmm that’s so
    pleasing; carry on the excellent work I’ll again visit your blogs to learn
    whole life insurance rate

  96. Free Says:

    It really works good!!

  97. felyhely Says:

    Hey thanks for such
    amazing blog! I have learnt a lot from there. Nice try!!!
    of Ra deluxe

  98. swaadd Says:

    شركة كشف تسربات المياه بالدمام
    شركة عزل أسطح بالدمام
    شركة عزل خزانات بالدمام
    كشف تسريب المياة بالدمام
    غسيل خزانات بالدمام
    افضل شركة تسليك مجارى بالدمام
    كشف تسربات المياة بالدمام والاحساء
    افضل شركة نظافة منازل بالاحساء
    كشف تسربات المياة بالدمام والاحساء
    كشف تسربات المياة بالاحساء
    افضل شركة كشف تسربات بالخبر
    شركة مكافحة الحشرات بالدمام والخبر
    افضل شركة نظافة بالدمام والخبر
    شركة عزل اسطح مبلطة وغير مبلطة بالجبيل
    شركة مكافحة حشرات بالجبيل
    شركة عزل اسطح بالجبيل
    شركة عزل مائى بالدمام والخبر والقطيف الجبيل
    كشف تسربات المياة بالدمام والخبر والقطيف والجبيل
    كشف تسربات المياة بالجبيل
    كشف تسربات المياة بالقطيف
    نظافة شقق بالدمام والقطيف
    شركة غسيل خزانات بالدمام الخبر القطيف
    كشف تسربات المياة بابقيق
    كشف تسربات المياة بابقيق
    كشف تسربات المياة بسيهات وعنك
    كشف تسربات المياة راس تنورة
    شركة سواعد
    شركة زهرة المدائن
    شركة مكافحة حشرات بالاحساء
    شركة تسليك مجارى بالاحساء شركة كشف تسربات بالاحساء
    شركة تسليك مجارى بالخبر
    شركة تسليك مجارى بالدمام

  99. felyhely Says:

    Your style is so
    exclusive compared to other individuals. Thank you for posting when you have
    the chance, guess I would just make this bookmarked.
    family health insurance companies

  100. felyhely Says:

    This blog is
    absolutely useful; I love the piece of informative writing.

    orogold reviews

  101. felyhely Says:

    Thanks a lot guys!
    What a great blog this is! It’s precious in favor of my knowledge.

  102. felyhely Says:

    Great blog and
    great writer that wrote this great piece of writing! Thanks
    vine vera skin care

  103. jeanettea Says:

    This is fine anyway
    nice try guys keep on hard working, truly nice info!
    Kitchen remodel Lakeville

  104. 037HD Com Says:

    ดูหนัง หนัง ดูหนังออนไลน์ หนังใหม่ ดูหนังฟรี 037HD 2015

  105. 9NUNG Says:

    thank you bro

  106. Coupons Mound Says:

    disqus is great plugin.

  107. keeef7 Says:


  108. ☯☯ Reimu ☯☯ Says:

    spam this

  109. ☯☯ Reimu ☯☯ Says:

    spam this

  110. 9NUNG Says: ดูหนัง

  111. PicoPalQueLeePontifexMɑximus®☪ Says:


  112. PicoPalQueLeePontifexMɑximus®☪ Says:


  113. Sergey Dragan Says:

    Thank you very much for this solution! Works like a charm.

  114. kik swishersweets08 Says:


  115. فرانكو سلاخ شبيحة 009 Says:


  116. Says:

    Fantastic! Thank you so much. For those who don’t know how to do what was mentioned in the article…thanks for this amazing sharing…

Theme Beantin created by James Royal-Lawson. Privacy Policy