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?

1 Answer 1


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.

  • 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, 2011 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, 2011 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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