Disabling/Enabling Comments To All Or Unregistered Users Only

There are different reasons why some webmasters would prefer to either enable the commenting feature to registered users only or to disable it completely from everybody. This tutorial is about how we can do the same to our blogs or sites.

Sometimes it’s easier to modify comment status and delete unwanted comments on a sitewide basis. A program like phpMyAdmin can make removing spam, closing/opening comments on old posts, etc. fairly easy. But before you proceed, it is always a good idea to backup your database.

Disabling and Enabling Comments

In the WordPress database, the “wp_posts” table includes a column called “comment_status”, which may contain one of the following values:

  • open (comments open to everyone)
  • closed (comments closed to everyone)
  • registered_only (comments open for registered/logged-in users)

Using the above info, we may execute the following SQL queries (via phpMyAdmin or any other similar method) to manipulate the comment settings (NOTE: again, make sure to backup your database first to be on the safe side):

Enable comments for ALL users

UPDATE wp_posts SET comment_status = 'open';

Disable comments for ALL users

UPDATE wp_posts SET comment_status = 'closed';

Enable comments for REGISTERED users only

UPDATE wp_posts SET comment_status = 'registered_only';

Enable/Disable comments before a certain date

Specify the comment_status (e.g. open, closed, registered_only) and then the date according to your preference.

UPDATE wp_posts SET comment_status = 'closed' WHERE post_date < '2008-01-01' AND post_status = 'publish';

Run this query a few times each year to disable comments on old posts.

And that’s how it’s done! Credits go to Jeff Star for sharing this helpful trick!

Incoming search terms for the article:

Related Posts

Simple Chat Plugin

eBag Toolkit

EWWW Image Optimizer

Twitter Cards PHP 1.1