Highlight Author Comments

Caveat

Unfortunately, due to ill-health, this plugin has not been developed or supported properly for some years. It works with the latest versions of WordPress (including on this website) but could possibly conflict with any WordPress features added after 2008 — e.g. custom post types — if you use them.

Purpose

Highlight Author Comments automatically displays comments made by a post’s author in a distinctive style with no need to edit your template files, etc. All you do is provide a snippet of CSS styling to be applied to author posts.

This is version 1.0.3 download latest version.

  • 1.0.3 accommodates inconsistencies in case of the email addresses used to locate author posts.
  • 1.0.2 adds new option to style the comment author link as well as the comment body; also fixes the collapsing paragraph bug.
  • 1.0.0 is the original version.

Installation Instructions

Highlight Author Comments is installed in 3 easy steps:

  1. Unzip the “Highlight Author Comments” archive and copy the folder to /wp-content/plugins/
  2. Activate the plugin
  3. Use the Options > Highlight Comment admin page to enter the CSS styling you want to apply to author comments.

Frequently Asked Questions

What Do I Enter in the Options Page?

The plugin Options page just has one text box where you put the bit of CSS you want to apply to highlighted comments. Don’t include { or }: just the CSS. For example, by default the plugin applies the CSS padding: 1em which ‘indents’ the comment a little all round. If you wanted to also make the text red, for example, you would use color: red; padding: 1em.

CSS Styling… What’s That?

Cascading Style Sheets (CSS) is too complex a subject to go into here. A good resource is provided by the Web Design Group.

How About Some Examples?

Here’s where some artistry would be a help! In lieu of skill here are some examples to play with:

  1. padding: 1em;
  2. padding-left: 20px;
  3. background-color: #FFFF95;
  4. border-left: 1em solid #DDD; padding: 1em;
  5. background: white url(http://www.yourblog.com/images/fluffy-clouds.gif)
  6. background-color: silver; margin-left: -2em; padding: 1em 1em 1em 2em;
  7. etc.

How Does It Know Which Comments to Highlight?

The plugin simply compares the email of the post author with the email of the commentor. This works fine as long as a post author is logged in when commenting. It will fail if the author is not logged in an uses a different email.

167 replies on “Highlight Author Comments”

  1. Because it’s hard to modify php files for em, I’ve wanted this.
    I just applied this plugin to my blog(wp 2.2.1) and it worked fine. Thank you for the plugin.

  2. Very nice plugin. I’ve been wanting this feature on all my blogs, none of whose themes currently implement the feature. Thanks for doing this.

    One problem I ran into was that you are doing an exact comparison of the email address. This only works if the email address is exactly the same, down to using the same casing. I implemented a modification to call strtolower when dong the comparison. You can see details here:

    http://dpotter.net/Technical/index.php/2007/10/28/highlight-author-comments-wordpress-plugin-review/

    Thanks again.
    David

  3. I’m very thankful for this plugin. Past plugins that I’ve seen like this were very limited because only one author per plugin could be specified. How you’re doing is how it should be done.

    I’m not a big fan of inline styling, and it isn’t a “web standards” best practice. One item, or “feature request”, would be to allow for class or id assignments instead inline styling.

    Also, being able to add a tag to a WordPress template instead of simply modding the comment_text() template tag. For example, being able to bold or color the author’s name would be a big benefit.

    That said, again I think this plugin is awesome. Good work and thanks!

  4. Schmelding: Thank you for your comments. I agree with you that inline styling isn’t to be generally recommended but in the context of a specific plugin I don’t see the problem. I decided against achieving the desired effect by adding a class because of the extra editing needed — I wanted the solution to be very simple for the novice.

    I like the idea of extending the plugin to be more flexible about what it can style. Can you explain your ‘tag’ idea a little more clearly for me?

  5. How about a threaded reply option, like Better Comment Manager? I love the functionality of Better Comment Manager, but I refuse to use it because it doesn’t integrate with the Manage Comments page…

  6. When I use your plugin, the author’s first line shows up in a bigger font and the background color, when used, does not fill in the last line of the post.

    I don’t know enough about css to figure out how to fix this.

    It works fine when I replace the comment.php file for use with brian’s threaded comments, probably because the brian plugin uses a replacement css. Unfortunately though I have been unable to work out the many complications of using that plugin with my theme.

    Interestingly your plugin also changes the background of all the comments, not just the author’s, when viewing the comments using the ajaxified “fold down” on the site.

    You have a great plugin and I’ll keep trying to get it to work properly.

  7. John: I’ve just been looking at the theme and it seems already set up to highlight author comments — at least it applies a style ‘bypostauthor’ to the right comments. All you should need to do is edit your css to do the job you want.

    My plugin tries to do the task for themes which don’t distinguish between comments. It wraps a styled div around the comment text. In the case of this theme the comments are already quite highly styled and it looks like the styles from the two sources are not interacting well. If you want to keep on with the plugin try using different styles till you find something that suits. I suspect the background is not going to work given the theme’s use of a background image (unless you invent an alternative one) — try just changing the colour of the text enough to stand out. Since the comment text looks slightly grey you could try ‘color: black’ for a start. Or you could pick up the blue colour you use for titles etc.

    Good luck!

  8. Quick question Rob. I think the way your code recognizes an “author” is based on the WP world, where the user’s email is registered. So this is the code you have:

    if ($comment->comment_author_email !== get_the_author_email())

    But for those of us who are importing our blog content from Movable Type or EE or something, this may or may not always apply.

    So I’m trying to modify the code you have in this simple but elegant plugin, as follows:

    	if (
    	     stristr($comment->comment_author_email, '@shanx.com')
    	  or stristr($comment->comment_author_name, 'Shanx')
    	  or stristr($comment->comment_author_url, 'shanx.com')
    	  )
      {

    The idea being: try to recognize the user from whatever method we can. But this isn’t working. Any ideas or thoughts?

  9. Brilliant, it works! Thanks.

    My only minor wishlist for this is that the DIV tag is wrapped around only the comment-text, not the whole comment with name, email, etc. I suppose that’s tought to do without too much hacking?

    I’m happy as it is. Thanks!

  10. Shanx: I agree with you but since I’m injecting the CSS via a WordPress hook I couldn’t find anything else suitable. If you have a brainwave let me know.

  11. mus: It would be best if they deactivated the plugin but the worst effect should just be some unwanted styling. The default extra styling is just a little extra padding.

  12. I’ve tried nearly 5 different ways of doing this, yours was by far the best talked out version to get me through it all. Thank you for finally making me understand this!

  13. Rob – I’m trying to do the same mod that Shanx mentioned above but it’s not working for my site. Can you repost what the PHP code will look like if you inserted Shanx’s strpos comments into the code section below? Thanks!

    function hac_highlight_comment($content){
    global $comment;
    if ($comment->comment_author_email !== get_the_author_email())
    return $content;
    else {
    $options = get_option(‘hac_highlight_author_comments’);
    return ”.$content.”;
    }
    }

  14. wildfire: It is hard to do that kind of thing in general. Shanx wanted to hard-wire some tests for specific substrings that identified himself. Basically he replaces the line:

    
    if ($comment->comment_author_email !== get_the_author_email())

    with

    
    if (strpos($comment->comment_author_email, 'shanx') !== false)
    

    Does that make sense? You would probably want to force both sides of the comparison to lower case too.

  15. Rob – thanks for that. Not sure what you mean by “force both sides of the comparison to lower case”, but this is exactly what I was trying to do with my code. Unfortunately it had the opposite effect – highlighting the comments that I didn’t make and leaving those that I did untouched. (obviously I changed the ‘shanx’ to my full email address in the example you list above) I’m not very knowledgeable about PHP, but would love to get your thoughts on this if you have any – as I’m also moving my blog from TypePad to WordPress and want to make this really cool feature retroactive for all my old posts!

  16. Rob – this works, but not as I had hoped. I was under the impression that Shanx’s string above worked if ANY of the three STRPOS strings were true, but it only seems to work if ALL of the three strings are true. Any suggestions as to how I can make it work, say, if the name and URL match but not the email? (in TypePad, I never asked for emails, so this data wasn’t collected – but in WP now is – so I’d like this flexibility)

  17. Maybe…

    
    if ( strpos($comment->comment_author_email, '@shanx.com') !== false || strpos($comment->comment_author_name, 'Shanx') !== false || strpos($comment->comment_author_url, 'shanx.com') !== false ) {
    	$options = get_option('hac_highlight_author_comments');
    	return '<div style="'.$options['highlight_style'].'">'.$content.'</div>';
    } else {
    	return $content;
    }
    
  18. Thank you very much, not only for designing a plug-in that’s extremely easy to use, but one that is needed (as I see it.)

    I’m using it now and happy too! 🙂

  19. hi rob, thanks for the plugins. im using the recent comments / similar posts and this one… simplistic and excellant! 🙂

    im not sure if you’ll be able to assist… though in regards to this plugin… is it possible to modify this script and add a “avatar image” as well?.

    thanks again!

  20. eric: At present all the plugin does is wrap the comment content in a styled DIV. It would be possible in a similar way to slip some code, like a gravatar call, before/after the content. Would that do what you would like?

  21. g`day rob.

    thanks for the reply.

    i’ve figured out how to insert the gravatar “standard” into the comments section (mind you… it too damn easy XD

    keep up the good work, will look forward for future updates on this and other plugs 🙂

  22. space: From the WordPress Dashboard you should see either a settings menu (in WP 2.5) or one called options (<2.5). Under that menu there should be an entry for 'Highlight' or 'Highlight Comments'.

  23. Woooohoooo!!!

    After three days, countless clicks, and feeling a bit churlish about editing my templates, can I just say I love your plug in! thanks for a simple to use, great looking solution.

    Kudos.

Comments are closed.