Welcome to Dagon Design. In addition to free scripts, WordPress plugins, and articles, we offer a variety of services including custom theme design, plugin creation, and PHP scripting. Contact me for more information.

Updated Friday, February 20th, 2009 at 8:20pm

Specify the user level needed to skip comment moderation in WordPress

This simple WordPress hack allows you to specify the minimum user level needed to post comments without moderation. By default, WordPress allows administrators (and the author of the post) to skip moderation checks when posting comments, but it is easy to adjust this so that you can choose the user level yourself. This can be useful for those of you who have strict comment moderation enabled (manual comment approval), as it allows you to let registered users of your site post immediately without having to wait for approval.

Requirements

This code modification has been verified to work in WordPress versions 2.1 through 2.8+

Instructions

Open wp-includes/comment.php

For WordPress 2.1 through 2.7.x, Find the following code:

if ( $userdata && ( $user_id == $post_author || $user->has_cap('level_9') 
) ) {
  // The author and the admins get respect.
  $approved = 1;

For WordPress 2.8, Find the following code:

if ( isset($userdata) && ( $user_id == $post_author || $user->has_cap('moderate_comments') ) ) {
  // The author and the admins get respect.
  $approved = 1;

Then simply change level_9 to whatever user level you want. All users at or above the selected level will be able to post comments without requiring manual approval (if you have manual approval enabled).

For a complete list of the user levels, and their roles, please see this page from the WordPress codex: http://codex.wordpress.org/Roles_and_Capabilities

  If you have found this page useful, please consider donating. Thanks!

  1. I wear moncler outlet jacket is warm and comfortable
    As a fan and consumer Moncler feel great, I wear Moncler jacket is warm and comfortable. It’s soft and light provided a lot of fun. In the cold winter, you don’t need to worry about the cold, just stay at home. Moncler doudoune will give you the most complete protection. As a famous brand, its outdoor sports level and the warm water surface removal troubles outdoor sports. This is a very good choice, for those who like skiing or other outdoor sports, especially in the winter is good choice, because Moncler man jacket, Moncler woman jacket and Moncler children will give you what you need.

    Maybe some question whether it is fashionable, because in the winter of enough, we not only need warm level and fashion. It is no doubt. The answer is yes. Look at those Fashionistas! In winter, they are the first choice Moncler jacket. Bright colors and fashionable design is simple, not only make out more comfortable, but also more fashionable. I remember one year winter is very cold, the shopping center all the shops and moncler vest were soon snapped up. Perhaps some of you are interested in store in the summer of jacket is a wise choice, to avoid the sale price, high peak.

  2. We supply all kinds of moncler boots,moncler bags,moncler coats,moncler jackets,moncler T-shirt,moncler vest and so on.We have got a good reputation pf our products with top quality and good price.We sincerely look forward to futher cooperation with you for mutual benefits.We are sure that you will find working with us is a pleasant, time-saving and profitable experience. Please feel free to contact us if you have any questions.Our website is http://www.newlyapparel.com.

  3. 3
    Ashok

    Thanks, this helped a lot. You could be a little more clearer for noobs though.

    For WP 2.8 and 2.9 – replace moderate_comments with level_9 or whatever you want it to be :)

  4. The instructions above have been updated to work with WordPress 2.8

  5. This code modification has been tested in the latest release of WordPress (2.7.1)

Leave a Comment

Before you comment: If you are having an issue with a script, please make sure you have read the entire article. Also, please read through the comments because most common issues have already been discussed many times. Thanks.


Be sure to wrap all code in <code></code> tags.