WordPress.org

Ready to get started?Download WordPress

Forums

Groups
[resolved] Query API (2 posts)

  1. Jayce
    Member
    Posted 1 year ago #

    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/

  2. itthinx
    Member
    Plugin Author

    Posted 1 year ago #

    $user = new Groups_User( $user_id );
    $groups = $user->__get( 'groups' );

    An example usage can be found in Groups_Shortcodes::groups_user_groups().

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.