WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to allow logged-in users to post comments without them being held for moderation, while requiring that any comment from anonymous users be approved? I have developed a system for users who are members of our organization to log in automatically with their LDAP accounts, and would like for any of them to be able to comment without their comments being held for moderation. However, I want all anonymous third-party comments to be held for moderation. I don't see any way to do that with the current comment options - I can either hold all comments for moderation, hold all comments by users without 2 approved comments, or require users to log in to comment. How can I achieve this?

share|improve this question
up vote 5 down vote accepted

Here you go, paste this code in your themes functions.php file:

function loggedin_approved_comment($approved)
    // No need to do the check if the comment is already approved anyway.
    if (!$approved) {
        if (is_user_logged_in()) {
            // Note: 1/0, not true/false
            $approved = 1;

    return $approved;

// Action allows the comment automatic approval to be over-ridden.
add_action('pre_comment_approved', 'loggedin_approved_comment');

Make sure to enable Comment Moderation inside the Settings-panel of your WordPress install.

share|improve this answer
Thanks for the handy code. This will probably work for my particular situation, but in the interest of a more adaptable solution, is there any way to actually add this to the settings panel as an option? – nhinkle Feb 5 '11 at 10:18
I guess so, you can create an options section and add it to the settings panel and based on that value run the function or add a check in the function for that value – Bainternet Feb 5 '11 at 15:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.