Posted By

Akuma99 on 11/27/09


Tagged

wordpresscommentsrole


Versions (?)

Wordpress comment style based on role


 / Published in: PHP
 

URL: http://www.wprecipes.com/wordpress-how-to-style-comments-of-every-roles

To do so, simply open your comments.php file and replace your comments loop by this one :

  1. <ol id="commentlist">
  2. <?php foreach ($comments as $comment) : ?>
  3. <?php // The extra stuff to get commenter's role
  4. $user_id = $comment->user_id;
  5. $role = ( isset( $roles[$user_id] ) ? $roles[$user_id] : '' );
  6. ?>
  7. <li class="<?php echo $role; ?>">
  8. <p>By <?php comment_author_link() ?> - <?php comment_date() ?></p>
  9. <?php comment_text() ?>
  10. </li>
  11. <?php endforeach; ?>
  12. </ol>
  13.  
  14. Once done, open yout style.css file and paste the following:
  15.  
  16. #commentlist li { border:2px solid white; } /* not logged or subscriber */
  17. #commentlist li.administrator { border:2px solid red } /* blog admin */
  18. #commentlist li.editor { border:2px solid blue } /* editor */

Report this snippet  

You need to login to post a comment.