WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] customizing list users

[Resolved] customizing list users

  • Hi I would like to modify this list user code

    $usernames = $wpdb->get_results("SELECT user_nicename, user_url FROM $wpdb->users ORDER BY ID DESC LIMIT 5");
    
    foreach ($usernames as $username) {
        echo '<li><a href="'.$username->user_url.'">'.$username->user_nicename."</a></li>";
    }

    so that admins are left out.
    Any help will be very appreciated
    thx

Viewing 2 replies - 1 through 2 (of 2 total)
  • vtxyzzy

    @vtxyzzy

    I believe you can use the user_can() function like this (UNTESTED):

    $usernames = $wpdb->get_results("SELECT ID, user_nicename, user_url FROM $wpdb->users ORDER BY ID DESC LIMIT 5");
    
    foreach ($usernames as $username) {
        if ( !user_can($username->ID,'administrator') ) {
           echo '<li><a href="'.$username->user_url.'">'.$username->user_nicename."</a></li>";
       }
    }

    Super! It works great….. ^__^

    Thx a lot vtxyzzy

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] customizing list users’ is closed to new replies.