Simple example of how to call get_users() in WordPress

I am new to advanced functonality in WordPress and I am just trying to understand how I would get a list of users somewhere in my WordPress site. I understand I have to call the function get_users() (http://codex.wordpress.org/Function_Reference/get_users) but I don’t know in which file (and where) I’d call this and therefore the URL I would use to call it?

I am hoping I could see super basic/bare minimum copy and paste example I could stick in my WP directory somewhere and just run to illustrate the issue for me.

Related posts

Leave a Reply

1 comment

  1. First of all you need to decide where you want the user list displayed (a page? home?), and it would help if you explained what you want to do with the list.

    Pick a template or make a new one, and all you have to do is call this function like this:

    <ul>
    <?php
        $blogusers = get_users('blog_id=1&orderby=nicename');
        foreach ($blogusers as $user) {
            echo '<li>Nick: ' . $user->user_nicename . '</li>';
            echo '<li>Name: ' . $user->display_name. '</li>';
            echo '<li>Email: ' . $user->user_email. '</li>';
        }
    ?>
    </ul>
    

    You do know you can get a list of users from inside the dashboard right? (…./wp-admin/users.php)