WordPress.org

Forums

The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Show gravatars of all authors and contributors, but not admins (1 post)

  1. Matthew Gerring
    Member
    Posted 7 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.