{"id":2977746,"date":"2012-08-18T13:39:48","date_gmt":"2012-08-18T13:39:48","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/plugin-groups-query-api\/"},"modified":"2016-08-20T15:02:57","modified_gmt":"2016-08-20T15:02:57","slug":"plugin-groups-query-api","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/plugin-groups-query-api\/","title":{"rendered":"[Plugin: Groups] Query API"},"content":{"rendered":"<p>Hello and thank you for this plugin. I&#8217;m looking for direction on using the API.<\/p>\n<p>I&#8217;m creating a plugin to let users search for other users on the WP front end. I&#8217;d like to limit the search query to specific Groups.<\/p>\n<p>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?<\/p>\n<pre><code>$args  = array(\n\t\/\/ search by Group\n\t\/\/ ??? &#039;group&#039; =&gt; &#039;X&#039;\n\t\/\/ Order by\n\t&#039;orderby&#039; =&gt; &#039;first_name&#039;,\n\t\/\/ check for two meta_values\n\t&#039;meta_query&#039; =&gt; array(\n\t\t array(\n\t\t\t  \/\/ by default compare is &#039;=&#039;\n\t\t\t  &#039;key&#039; =&gt; &#039;active&#039;,\n\t\t\t  &#039;value&#039; =&gt; &#039;1&#039;,\n\t\t  ),\n\t\t \/\/ add more\n));\n\n$wp_user_query = new WP_User_Query($args);\n\n\/\/ Get the results\n$qresults = $wp_user_query-&gt;get_results();<\/code><\/pre>\n<p>https:\/\/wordpress.org\/extend\/plugins\/groups\/<\/p>\n","protected":false},"template":"","class_list":["post-2977746","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/2977746","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/2977746\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=2977746"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}