Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Website: [removed]

If you goto the above post you will see that there are some comments which when posted appears as admin comments for some reason.

If you are having problem finding that specific comment you can also press CTRL+F to find it using the following words Test Comment or Guest which i posted myself for testing purpose to show it here.

The problem is that its making guest users comment appear as Admin Comments by putting that ADMIN Image at the right of the comments. and the odd thing is this is only happening if the user replies to an admin comment :o

Can someone please help and tell me what could be causing this behavior? i'm pretty new to wordpress theme development :(

Thanks in advance.

share|improve this question
    
I'm not sure which post to mark as the solution :o @Rarst has helped me figure out my issue, while @kaiser provided a nice alternative solution for my problem. –  Zubair1 Feb 9 '11 at 15:12
1  
If more than one answer helped solve the problem, mark the one that was most useful as the answer and make sure you up-vote both of them. The idea is that the most helpful answer will float to the top - most helpful meaning most complete, most direct, best code example, etc. –  EAMann Feb 9 '11 at 16:20
    
@EAMann♦ I chose the best solution (which would not only help in my situation but others aswell). but i liked both and at the moment can't vote up either up. due to me having not enough points, just need 2 more to do so. I'll come back later if remember to vote them up (if i can by then). thank you for your help too :) –  Zubair1 Feb 9 '11 at 17:20

2 Answers 2

up vote 3 down vote accepted

styles.css > line 537: (span.poster-roles)

You haven't defined ...

  • any offset to differ between author and admin for the sprite (author/admin)
  • any additional class to make a difference between author/admin

It seems that you wanted to only add the graphic for registered authors and admins (there's nothing for guests).

You'll need to add ...

(on top of your comments template/file)
global $current_user;
get_currentuserinfo();
$user_ID = $current_user->user_ID;
$the_user = get_userdata( $user_ID );

(inline - comment div) a class for authors & admins like

<span class="<?php   
if ( !empty($the_user) ) :  
  echo $the_user->wp_capabilities->role;   
else :  
  echo 'guest';  
endif;  
?>">

Then do some offset for the class mentioned above like

ol.commentlist li.comment ul.children li.comment-author-admin .poster-roles.admin { 
   background-position: 0px 0px;
}  
ol.commentlist li.comment ul.children li.comment-author-admin .poster-roles.author {
   background-position: 0px -40px;
}

I don't know exactly if it's wp_capabilities->roles, so please refer to some of my old (since a long time not further developed) plugins for the exact user info - your friendly current user deamon.

share|improve this answer
1  
Ok Zubair... The "third party" is me. Second: The plugin only gives you information about any data provided for the currently logged in user. Activate it, search for the wp-capabilities array in the current user object and then replace "role" in $the_user->wp_capabilities->role from above with whatever you need to get the role added. ok? It's a development plugin and you can drop it, when you are finished, so it won't be needed in the live environment. Anyway: This was a lot of effort & includes the sollution, so i would highly appreciate if you vote it up and mark it as the sollution. –  kaiser Feb 9 '11 at 14:12
1  
The plugin is pointless for me, all it does is show variable and it's values i can see all those values with the plugin. But still i see the solution you provided and i surely would have gone with that approch. if i hadn't figured out a simpler solution myself. which was done using simple css tweaks rather than fiddling with the php code. –  Zubair1 Feb 9 '11 at 15:07
1  
i did use the admin/author approch but earlier in my comments template i defined a span with class .poster-roles i removed that. and instead am using the default classes provided by wordpress to add the graphic to admin and authors. I was doing the same before but i added a extra span (as i said earlier) to show that graphic and css was inheriting that graphic for child comments too. The Solution you gave was to fetch the poster roles using php values, but wordpress auto generates classes. to see if poster is an admin/author or user (this is what i was doing from the start) but css had issues –  Zubair1 Feb 9 '11 at 15:48
1  
I would surely vote it up, but i dont have enough points to do that. For the solution i'm not sure which to choose since they're both helpful to me so i called for mod to help decide. –  Zubair1 Feb 9 '11 at 15:55
1  
Didn't know you used the wp comment class fn. Would have worked too: $comment_class = 'poster-'.(!empty( $the_user ) ? $the_user->wp_capabilities->role : 'guest'); comment_class( $comment_class ); –  kaiser Feb 9 '11 at 15:56

This has little to do with WordPress and is mostly theme's CSS styling issue.

That admin image is added with following CSS rule in style.css:

ol.commentlist li.comment-author-admin .poster-roles {
    background: url("images/poster-roles-bg.png") no-repeat scroll right top transparent;
}

Which roughly means - add image to roles block inside admin block. The issue is that your nested comments are also technically inside admin block and rule cascades to them.

share|improve this answer
    
thanks i think i get it now, but how do i fix this? –  Zubair1 Feb 9 '11 at 13:13
1  
I got fixed now thanks :) i removed the span (.poster-roles) completely and used the main background to add the graphics for the admin and authors. –  Zubair1 Feb 9 '11 at 13:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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