1

I don't know if this is possible, I've searched around but came up short. Basically, I need that the current user who is commenting to see his comments slightly different than the rest.

I'm doing this for admins/moderators, but the thing is that all users see the highlighted comments made by admin/mod, where here I just want every user to see his comments as highlighted.

2

assumes that your theme is using comment_class();

example (to be added to functions.php of your theme):

add_filter( 'comment_class', 'comment_class_logged_in_user' );

function comment_class_logged_in_user( $classes ) {
    global $comment;
    if ( $comment->user_id > 0 && is_user_logged_in() ) {
        global $current_user; get_currentuserinfo();
        $logged_in_user = $current_user->ID;
        if( $comment->user_id == $logged_in_user ) $classes[] = 'comment-author-logged-in';
    }
return $classes;
}

requires formatting of the css class:

.comment-author-logged-in { }

I recently posted a plugin version in my site.

0

First, if you look at the comment classes, you will notice a class called byuser. That class is one of the default classes added by comment_class. That is all you need. You can style that with CSS however you want.

If you theme is not using comment_class as it should be then...

Look in your theme's comments.php for a function named wp_list_comments. In Twenty Twelve it looks like this: wp_list_comments( array( 'callback' => 'twentytwelve_comment', 'style' => 'ol' ) );.

That callback part is the important part here. If there is a callback in your theme's function call, that is what you need to alter. If there is no callback the WordPress default will be used so there should be no problem. comment_class should already be in use.

The theme should have a function named the same as that callback's value in the code above. For Twenty Twelve it is twentytwelve_comment which is defined in functions.php. That formats and displays the actual comment list. All you should need to do is duplicate/edit that function and add the comment_class function, right around here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.