WordPress.org

Support

Support » Plugins and Hacks » Show gravatars of all authors and contributors, but not admins

Show gravatars of all authors and contributors, but not admins

  • Hello all,

    I am using this code to grab the gravatars of all the users on a site, and it excludes the site admin, but I also want to exclude anyone with the user level of ‘admin’ and only include contributors and authors.

    <?php
    	$site_admin = "1";
        $user_ids = $wpdb->get_col("SELECT ID FROM $wpdb->users WHERE ID != '$site_admin' ORDER BY user_nicename"); // query users
        foreach($user_ids as $user_id) : // start authors' profile "loop"
        $user = get_userdata($user_id);
        ?>
        <div class="recent thumb"><a href="<?php bloginfo('url'); ?>/author/<?php echo $user->user_nicename; ?>" title="<?php echo $user->user_nicename; ?>"><?php echo get_avatar($user->user_email, '42', $avatar); ?></a></div>
        <?php
        endforeach; // end of authors' profile 'loop'
        ?>

    I don’t know much about using SELECT. I imagine the user level is somewhere in the users table, but I don’t know where, or the right syntax for excluding those user levels. Can anyone help?

  • The topic ‘Show gravatars of all authors and contributors, but not admins’ is closed to new replies.