WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display Newest Subscribers (4 posts)

  1. depiction
    Member
    Posted 5 years ago #

    Is it possible to display the 4 or 5 newest members or subscribers in the sidebar? I have searched both Google and here at wordpress.org and can not find any plugin that could do this. I am aware of the wp_list_authors tag, but I want to list subscribers. I find no evidence that wp_list_subscribers tag exists.

  2. wp_guy
    Member
    Posted 5 years ago #

    wp_list_authors works for that too... you just need to set the 'hide_empty' parameter to false (because subscribers don't write posts). Something like this:

    <?php wp_list_authors("hide_empty=0"); ?>

    The only problem now is that there doesn't seem to be a way to limit the number of subscribers you want to show.

  3. wp_guy
    Member
    Posted 5 years ago #

    Ok... I found something better:

    <?php
        $subscribers = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY user_registered DESC");
        for($i=0;$i<4;$i++){
            echo "<li>".$subscribers[$i]->user_nicename."</li>";
        }
    ?>
  4. depiction
    Member
    Posted 5 years ago #

    Thanks a lot wp_guy. The code you provided worked great.

Topic Closed

This topic has been closed to new replies.

About this Topic