Title: [Plugin: Groups] Query API
Last modified: August 20, 2016

---

# [Plugin: Groups] Query API

 *  Resolved [Jayce](https://wordpress.org/support/users/jaycetech/)
 * (@jaycetech)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-groups-query-api/)
 * Hello and thank you for this plugin. I’m looking for direction on using the API.
 * I’m creating a plugin to let users search for other users on the WP front end.
   I’d like to limit the search query to specific Groups.
 * Can I use WP_User_Query to find only users in Groups X? Or does the Groups API
   offer some other way to accomplish this?
 *     ```
       $args  = array(
       	// search by Group
       	// ??? 'group' => 'X'
       	// Order by
       	'orderby' => 'first_name',
       	// check for two meta_values
       	'meta_query' => array(
       		 array(
       			  // by default compare is '='
       			  'key' => 'active',
       			  'value' => '1',
       		  ),
       		 // add more
       ));
   
       $wp_user_query = new WP_User_Query($args);
   
       // Get the results
       $qresults = $wp_user_query->get_results();
       ```
   
 * [http://wordpress.org/extend/plugins/groups/](http://wordpress.org/extend/plugins/groups/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [itthinx](https://wordpress.org/support/users/itthinx/)
 * (@itthinx)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-groups-query-api/#post-2977826)
 *     ```
       $user = new Groups_User( $user_id );
       $groups = $user->__get( 'groups' );
       ```
   
 * An example usage can be found in `Groups_Shortcodes::groups_user_groups()`.

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Groups] Query API’ is closed to new replies.

 * ![](https://ps.w.org/groups/assets/icon-256x256.png?rev=983146)
 * [Groups](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/)

 * 1 reply
 * 2 participants
 * Last reply from: [itthinx](https://wordpress.org/support/users/itthinx/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-groups-query-api/#post-2977826)
 * Status: resolved