Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. $display_admins = false;
  2. $order_by = 'display_name'; // 'nicename', 'email', 'url', 'registered', 'display_name', or 'post_count'
  3. $role = ''; // 'subscriber', 'contributor', 'editor', 'author' - leave blank for 'all'
  4. $avatar_size = 32;
  5. $hide_empty = true; // hides authors with zero posts
  6. $last = '';
  7.  
  8. if(!empty($display_admins)) {
  9. $blogusers = get_users('orderby='.$order_by.'&role='.$role);
  10. } else {
  11. $admins = get_users('role=administrator');
  12. $exclude = array();
  13. foreach($admins as $ad) {
  14. $exclude[] = $ad->ID;
  15. }
  16. $exclude = implode(',', $exclude);
  17. $blogusers = get_users('exclude='.$exclude.'&orderby='.$order_by.'&role='.$role);
  18. }
  19. $authors = array();
  20. foreach ($blogusers as $bloguser) {
  21. $user = get_userdata($bloguser->ID);
  22. if(!empty($hide_empty)) {
  23. $numposts = count_user_posts($user->ID);
  24. if($numposts < 1) continue;
  25. }
  26. $authors[] = (array) $user;
  27. }
  28.  
  29. echo '<ul class="contributors">';
  30. foreach($authors as $author) {
  31. $current = strtolower($author['data']->display_name[0]);
  32. $display_name = $author['data']->display_name;
  33. $avatar = get_avatar($author['ID'], $avatar_size);
  34. $author_profile_url = get_author_posts_url($author['ID']);
  35.  
  36. if ($last != $current) {
  37. echo '<a class"alphabit" name="' . strtoupper($current) . '">' . strtoupper($current) . '</a>';
  38. $last = $current;
  39. }
  40. echo '<li><a href="', $author_profile_url, '">', $avatar , '</a><a href="', $author_profile_url, '" class="contributor-link">', $display_name, '</a></li>';
  41. }
  42. echo '</ul>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement