Title: WP_User_Query by Group
Last modified: August 24, 2016

---

# WP_User_Query by Group

 *  Resolved [jduffell](https://wordpress.org/support/users/jduffell/)
 * (@jduffell)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/wp_user_query-by-group/)
 * I’m using the groups plugin to create to help organise my users ([https://wordpress.org/plugins/groups/](https://wordpress.org/plugins/groups/))
   so I have a group called ‘retired’. I have a WP_User_Query which is working perfectly
   I just can’t figure out how I take what I’ve got to only display users in the
   group ‘retired’.
 * I’ve currently got it to exclude anyone missing a profile picture and it displays
   users of a position pulled in from a variable. Any pointers much appreciated.
   Cheers
 *     ```
       $args  = array(
       'role'      => 'talent',
       'order'     => 'DESC',
       'orderby'   => 'user_registered',
       'meta_key'  => 'position',
       'number'    => '15',
       'meta_query'=> array (
           array(
               'key'       => 'picture',
               'value'   => array(''),
               'compare' => 'NOT IN'
           ),
           array(
               'key'       => 'position',
               'value'     => $title
           ),
       )
       );
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [gtsiokos](https://wordpress.org/support/users/gtsiokos/)
 * (@gtsiokos)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/wp_user_query-by-group/#post-6075125)
 * Hi jdufell,
 * You can use this
 *     ```
       $is_a_member = false;
       require_once( ABSPATH . 'wp-includes/pluggable.php' );
       if ( $group = Groups_Group::read_by_name( 'Foobar' ) ) {
       $is_a_member = Groups_User_Group::read( get_current_user_id() , $group->group_id );
       }
       ```
   
 * found in [documentation examples](http://docs.itthinx.com/document/groups/api/examples/),
   of course you have to modify it to check with each one of the users in your array.
 * Cheers
 *  Thread Starter [jduffell](https://wordpress.org/support/users/jduffell/)
 * (@jduffell)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/wp_user_query-by-group/#post-6075226)
 * Hi gtsiokos,
 * Cheers for that, I came across this and actually use it on profiles to output
   the user level which works quite well, I was trying to get users with a specific
   group at with WP_User_Query so that I could get 15 profiles, if I run the above
   within the actual loop and only 5 users belong to a certain queried group, the
   other 10 results would be redundant. So by filtering via the actual query I was
   hoping to eliminate that issue if that makes sense?
 * Cheers for the response though, much appreciated.
 *  [gtsiokos](https://wordpress.org/support/users/gtsiokos/)
 * (@gtsiokos)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/wp_user_query-by-group/#post-6075239)
 * Hi jduffell,
 * Perhaps i’ve misunderstood. What i meant was after running the WP_User_Query 
   with your specific arguments, to filter these results through the example i proposed
   above.
 * It’s an interesting idea what you’re trying to do.
 * Cheers

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘WP_User_Query by Group’ is closed to new replies.

 * ![](https://ps.w.org/groups/assets/icon-256x256.png?rev=983146)
 * [Groups - Memberships and Access Control](https://wordpress.org/plugins/groups/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/groups/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/groups/)
 * [Active Topics](https://wordpress.org/support/plugin/groups/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/groups/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/groups/reviews/)

## Tags

 * [wp_user_query](https://wordpress.org/support/topic-tag/wp_user_query/)

 * 3 replies
 * 2 participants
 * Last reply from: [gtsiokos](https://wordpress.org/support/users/gtsiokos/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/wp_user_query-by-group/#post-6075239)
 * Status: resolved