I received a few emails asking me about the tagging description that I put next to the commenters name in the comment section. I did not use a plugin for that and I just hack a quick code in my functions.php. It is a pretty way to show who’s who on your blog.
Download the functions below. It will be easier for you to read it. Explanations are also provided in this file.

The CSS
So let me share the CSS code first. You can tweak it the way you want it. I’ll just share the current version of CSS that I have for this code snippet.
/* Main Style for the Tags */
span.user-tag {
font-size:9.5px;
text-transform:uppercase;
-webkit-border-radius:2px;
-moz-border-radius:2px;
border-radius:2px;
padding:1px 2px;
}
/* Post Author Tag (That'll be you) */
span.user-tag.bypostauthor {
background:#fe57a1;
bottom:2px;
color:#FFF;
font-size:9.5px;
margin-left:5px;
position:relative;
padding:3px 5px;
}
/* Best Buds Tag (That'll be your friends) */
span.user-tag.bestbuds {
background:#204117;
bottom:2px;
color:#FFF;
font-size:9.5px;
margin-left:5px;
position:relative;
padding:3px 5px;
}
The functions.php
This is where the fun begins! You should put this code in your functions.php. Put each of your commenters’ email in an array. We will use their emails to determine who’s who on your blog, just like Gravatar. We will use a WordPress built-in function to get the commenter’s email: get_comment_author_email($comment).
Group them by their categories. In my case, I group them as “blogging buddy”, “best buds”, etc. Then, you can just display the HTML span line according to each group. You can achieve this by using conditional statement (if/else).
function bones_user_tag($comment) {
// Blogging buddy array
$blogging_buddy = array('someone@something.net', 'b@aa.net');
// Best buds array
$best_buds = array('someone@something.net', 'some@some.net');
// Blogging buddy and best buds array
$blogging_buddy_and_best_buds = array('b@aa.net');
// Conditional Statement starts here
// Comment Author/Blog Owner
if (1 == $comment->user_id) {
echo '<span class="user-tag bypostauthor">Author</span>';
// Blogging Buddy
} elseif (in_array(get_comment_author_email($comment), $blogging_buddy)) {
echo '<span class="user-tag popularcommenter">Blogging Buddy</span>';
// My Mom. Did not use any arrays here. I only have one mom
I just use the old '==' sign
} elseif (get_comment_author_email($comment) == "something@gmail.com") {
echo '<span class="user-tag mom">Hello Mommy!</span>';
// My Best Buds
} elseif (in_array(get_comment_author_email($comment), $best_buds)) {
echo '<span class="user-tag bestbuds">Best Buddy</span>';
// My best buds who happened to be my blogging buddy as well
} elseif (in_array(get_comment_author_email($comment), $blogging_buddy_and_best_buds)) {
echo '<span class="user-tag popularcommenter">Blogging Buddy</span>';
echo '<span class="user-tag bestbuds">Best Buddy</span>';
}
}
We will first check if the comment belongs to the blog owner. If it doesn’t, it will go through the elseif line. We use the in_array method to check whether the array contains the commenter’s email. in_array(get_comment_author_email($comment), $best_buds) code will check whether $best_buds array contains the commenter’s email. If it returns true, it will show the colored tags. Otherwise, it will return nothing.
Calling the Function
After you had created the function, you need to call it somewhere. You call it next to where you would output your commenter’s name. This is how my comments function look like. The newly added function is highlighted in grey.
<article id="comment-<?php comment_ID(); ?>" class="clearfix">
<header class="comment-author vcard">
<?php echo get_avatar($comment,$size='50',$default='<path_to_url>' ); ?>
<?php printf(__('<cite class="fn">%s</cite>'), get_comment_author_link()) ?>
<time datetime = "<?php echo get_comment_date('c'); ?>"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s'), get_comment_date(), get_comment_time()) ?></a></time>
<?php edit_comment_link(__('(Edit)'),' ','') ?>
// user tag function is added here:
<?php bones_user_tag($comment); ?>
</header>
My comment code may look different than yours but you get the idea: just call the function next to your commenters’ name. Call it like this: <?php bones_user_tag($comment); ?>
What if your one of your commenters have multiple role? For example, Flippy Doodle here is both my blogging buddy and one of my best buds (we know each other in real life).

In this case, I just create an array named $blogging_buddy_and_best_buds and just use the in_array function again to check whether the commenter’s email match any of the array values. I included this in the code snippet above. You can refer to it or download the file that is provided for you.
Anyway, try this out and see if it works. Post your questions here if you have one. In the mean time, I’ll try and make the code above more elegant. It was a quick hack anyway.
Happy tagging! (I think it is about time that I change the style of my pre code tag. It makes the code look messy and hard to read. Sorry if you have trouble reading them. Just download the file above if you must.
)
