Many WordPress users wish to visually highlight their own responses between the comments on a post, so that you recognize at the first glance which comments come from the site operator and which ones from normal visitors. So do I.
A Google search revealed that it is most often being recommended to simply compare the commentator’s user ID with your own one, and if they match, assign a second, special CSS class to the comment. That would look something like this:
<li class="comment<?php if($comment->user_id == 1) echo ' admincomment'; ?>">
I don’t like that very much. What if a site has multiple writers and you would like to highlight the comments of all of them? Should it look like this then?
<li class="comment<?php if($comment->user_id == 1 || $comment->user_id == 3 || $comment->user_id == 13 || $comment->user_id == 753) echo ' admincomment'; ?>">
I think we all agree that this is not very beautiful. ;) Besides, each time you admit a new member to your “editorial team”, you would have to fiddle around with the template again in order to enter his user ID there.
No, no, that’s not the way you do it. It would be a lot better if you simply checked the commentator’s user level, because if it is above 0, you know that you are dealing with one of the site’s “staff members”.
That will look like this:
<? $userdata = get_userdata($comment->user_id); ?> <li class="comment<?php if($userdata->user_level > 0) echo ' admincomment'; ?>">
This way, all comments from contributors (level 1), authors (level 2–4), editors (level 5–7) and admins (level 8–10) will get a different style. Of course, you can even refine the whole thing with the aid of these levels, e. g. if you only want to change the appearance of admin and editor comments, but not the one of author and contributor comments.