WordPress.org

Support

Support » Themes and Templates » list users by role

list users by role

  • hi!

    i use the tag wp_list_authors(); to list my users on page!

    but i want that this list is sorting by role:

    role 1:
    – user 1
    – user 7
    – user 4

    role 2:
    – user 2
    – user 3
    – user 5

    etc

    but this tag only show user sorting [A-Z]

    any idea?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hm, can’t find a function to get users’ roles but you can write your own mysql query or write the list by hand.

    Hi

    try this code, let me know if u have any questions?

    $users_of_blog = get_users_of_blog();

    //var_dump($users_of_blog);
    $contributor = array();
    $subscriber = array();
    $author = array();
    foreach ( (array) $users_of_blog as $b_user ) {

    $b_roles = unserialize($b_user->meta_value);
    foreach ( (array) $b_roles as $b_role => $val ) {

    if($b_role==’contributor’){
    array_push($contributor,$b_user->display_name);
    }
    if($b_role==’subscriber’){
    array_push($subscriber,$b_user->display_name);
    }
    if($b_role==’author’){
    array_push($author,$b_user->display_name);
    }

    }
    }

    <table width=”100″ border=”0″ cellspacing=”0″ cellpadding=”0″>
    <tr>
    <td align=”left”>Contributors</td>
    <td> </td>
    </tr>
    <?php
    $ccount = count($contributor);

    for ($i = 0; $i <= $ccount; $i++) {

    ?>
    <tr>
    <td align=”left”><?php echo $contributor[$i]?></td>
    <td> </td>
    </tr>
    <?php } ?>
    <tr>
    <td> </td>
    <td> </td>
    </tr>
    </table>

    Sivac,

    Thankyou for the contribution. This is exactly what I needed to finish an application for staff rosters. Might make a useful plugin too.

    Cheers.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘list users by role’ is closed to new replies.
Skip to toolbar