temanızın functions.php dosyasına:
function fb_list_authors($userlevel = 'all', $show_fullname = true) {
global $wpdb;
/*
all = Display all user
1 = subscriber
2 = editor
3 = author
7 = publisher
10 = administrator
*/
if ( $userlevel == 'all' ) {
$author_subscriper = $wpdb->get_results("SELECT * from $wpdb->usermeta WHERE meta_key = 'wp_capabilities' AND meta_value = 'a:1:{s:10:\"subscriber\";b:1;}'");
foreach ( (array) $author_subscriper as $author ) {
$author = get_userdata( $author->user_id );
$userlevel = $author->wp2_user_level;
$name = $author->nickname;
if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') ) {
$name = "$author->first_name $author->last_name";
}
$link = '<li>' . $name . '</li>';
echo $link;
}
$i = 0;
while ( $i <= 10 ) {
$userlevel = $i;
$authors = $wpdb->get_results("SELECT * from $wpdb->usermeta WHERE meta_key = 'wp_user_level' AND meta_value = '$userlevel'");
foreach ( (array) $authors as $author ) {
$author = get_userdata( $author->user_id );
$userlevel = $author->wp2_user_level;
$name = $author->nickname;
if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') ) {
$name = "$author->first_name $author->last_name";
}
$link = '<li>' . $name . '</li>';
echo $link;
}
$i++;
}
} else {
if ($userlevel == 1) {
$authors = $wpdb->get_results("SELECT * from $wpdb->usermeta WHERE meta_key = 'wp_capabilities' AND meta_value = 'a:1:{s:10:\"subscriber\";b:1;}'");
} else {
$authors = $wpdb->get_results("SELECT * from $wpdb->usermeta WHERE meta_value = '$userlevel'");
}
foreach ( (array) $authors as $author ) {
$author = get_userdata( $author->user_id );
$userlevel = $author->wp2_user_level;
$name = $author->nickname;
if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') ) {
$name = "$author->first_name $author->last_name";
}
$link = '<li><b>' . $userlevelname[$userlevel] . '</b></li>';
$link .= '<li>' . $name . '</li>';
echo $link;
}
}
}ekleyin.
daha sonra sidebar.php içerisine;
Sadece yöneticiler ve sadece kullanıcı adları için:
<ul>
<?php fb_list_authors(10, FALSE); ?>
</ul>
Tüm kullanıcılar, isim ve soyisimleriyle birlikte listelemek için:
<ol>
<?php fb_list_authors(); ?>
</ol>
Sadece aboneler, isim ve soyisimleriyle birlikte listelemek için:
<ul>
<?php fb_list_authors(1, TRUE); ?>
</ul>
kodunu ekleyin.
kaynak:
http://wpengineer.com/365/list-all-users-in-wordpress/