Subscribe to RSS

WordPress: Author comment highlighting

I’ve seen it lots of times before, but I just added it to Ariejan.net (and the next release of the iAriejan theme). Sometimes there are lots of comments and it’s nice for visitors to see what the official reaction of the blog author is.

Since I haven’t really looked into a plugin or anything, this is just a very simple theme hack.

You can apply it to your current theme with almost no effort at all.

Open up your comments.php file in your themes directory. And look for the following code:

[php]

  • comment_author_email == get_the_author_email() ) echo ‘authorcomment’; else echo $oddcomment; ?>” id=”comment-< ?php comment_ID() ?>” id=”comment-< ?php comment_ID() ?>“>[/php]

    What this will do is match the e-mail address of the poster with the e-mail address of the post author. This is in some way spoofable, as users may be able to post a comment with your e-mail address on it.

    If you posted the comment an extra CSS class named ‘authorcomment’ is added. So add the following to your style.css file. (You may change this to suit your own taste of course):

    [css].authorcomment {
    background-color: #363636;
    border: 1px solid #969696;
    }[/css]

    To prevent this you can add your e-mail address (the one you use with your WP account) to Options -> Discussion -> Comment Moderation. This will keep any post that contains your email address back for moderation by you. This is the only fool-proof method I know right now to keep people from spoofing. There might be some other hacks for this, but I haven’t had time to think about that yet.

  • Please share the love of this post by bookmarking it, and sharing it with others. Thanks!

    • Digg
    • del.icio.us
    • description
    • Reddit
    • Technorati
    • BlinkList
    • E-mail this story to a friend!
    • Facebook
    • Live
    • MisterWong
    • Netvouz
    • NewsVine
    • Slashdot
    • SphereIt

    6 Comments

    1. Posted 22 November, 2006 at 11:51 | Permalink

      As you can see here, it works :)

    2. Posted 27 November, 2006 at 13:22 | Permalink

      Brilliant! That’s just the sort of thing I’ve been after but always forget to look up. Will it work if I’m logged in as admin or do I have to be entering an email in the section?

      Actually, I suppose I’ll just try it & see - thanks :)

      Oh PS - I had this page open in another tab & it stopped me from commenting with a 15 second split needed between comments. I really liked that - very swish.

    3. Posted 10 March, 2007 at 14:26 | Permalink

      Nice Work for me :)but if some one comment by my email wht should i do?

    4. Posted 24 May, 2007 at 18:45 | Permalink

      This code just alternated the color for me instead of doing what I wanted. I changed the code a bit and got it the way I liked using this:

      comment_author_email == get_the_author_email() ) echo ‘class=”authorcomment”‘; else echo $oddcomment; ?> id=”comment-”>

      A very nice modification though :)

    5. Posted 11 September, 2007 at 09:48 | Permalink

      I have visited your site 393-times

    6. Posted 11 September, 2007 at 09:48 | Permalink

      Your site found in Google: http://google.com/search?q=sqd

    Post a Comment

    Your email is never published nor shared. Required fields are marked *

    *
    *