Support » Fixing WordPress » Do I have to approve my own comments?

  • WP 1.5 in testbed.
    Discussion Options set to:
    x – An administrator must approve the comment (regardless of any matches below)
    x – Comment author must fill out name and e-mail

    I am logged in as the admin (it even recognizes me 🙂 and trying to post a test comment to a test post. Actually I can, but it puts it into the moderation queue.
    Is there a way that I can “auto-approve” my own comments?

Viewing 10 replies - 1 through 10 (of 10 total)
  • You can do this by adding just a couple lines to wp-includes/functions-post.php. Look in this file for the function wp_new_comment() (around line 450).

    Just before this line in the function:

    $approved = apply_filters('pre_comment_approved', $approved);

    Add this:

    if ( 1 == $user_id )
    $approved = 1;

    Change the number matched against $user_id to the numeric ID of the account you wish to auto-approve.

    Note: back up source files you plan to edit, and comment your changes (so you can find them later).

    Thanks Kafkaesqui!
    I’ll try to implement it. Though I still have a (rhetoric?) question: since usually the user with id# 1 is the default admin created during the install – or am I wrong? – wouldn’t be expected that the fix you provided was there “by default”???
    Just my 2 cents 🙂

    User ID 1 is pretty much always the “admin” acccount yes. Then again, not everyone uses it all the time (I myself have a secondary account for posting, etc), so one may want to change it in the bit of code I have above. Anyway, I hope your question wasn’t rhetorical, considering I answered it. ;~)

    As to what’s in the source by default, that’s sort of up to the devs. Well, it’s also up to us too, to make suggestions and offer up solutions. You never know.

    Kaf, as an aside, is this info in the Codex? I haven’t seen it and it is something that has irritated me in the past but I just let it slide. It’s a good thing to add.


    Personally I’m averse to recommending core source code changes as part of the “official” documentation. But if you can figure a good place to fit it in…

    I know, but this is annoying – So make them change the source code….

    <small>who am I to demand such things….</small>

    Something like this shouldn’t be too hard to make into a plugin…I’ll see what I can do.

    I tried adding this code but it didn’t seem to make any difference. I must have done something stupid I suppose but I can’t think what.

    don’t know if you are still working on this MtDewVirus, but consider amending it slightly.

    rather than just using a user id, would it be possible to allow all ‘logged in’ members to post comments without them being moderated, and all the rest get held in the queue.

    It isn’t quite the same as whitelisting, which is open to abuse, especially if it only checks on email address..

    Official Comments

    may well be what I suggested!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Do I have to approve my own comments?’ is closed to new replies.