• Resolved alby54

    (@alby54)


    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)
  • 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>";
       }
    }
    Thread Starter alby54

    (@alby54)

    Super! It works great….. ^__^

    Thx a lot vtxyzzy

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