Title: [Plugin: Groups] Is there a PHP function like get_user_group()?
Last modified: August 20, 2016

---

# [Plugin: Groups] Is there a PHP function like get_user_group()?

 *  Resolved [rthakrar](https://wordpress.org/support/users/rthakrar/)
 * (@rthakrar)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-groups-is-there-a-php-function-like-get_user_group/)
 * Hi,
 * I’d like to create some if statements based on user groups, so was looking for
   a function like get_user_group() to give me a variable to work with. Is there
   a function I can use?
 * Thanks,
 * R
 * [http://wordpress.org/extend/plugins/groups/](http://wordpress.org/extend/plugins/groups/)

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

 *  Plugin Author [itthinx](https://wordpress.org/support/users/itthinx/)
 * (@itthinx)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-groups-is-there-a-php-function-like-get_user_group/#post-2981091)
 * See [http://wordpress.org/support/topic/plugin-groups-query-api](http://wordpress.org/support/topic/plugin-groups-query-api)
 *  Thread Starter [rthakrar](https://wordpress.org/support/users/rthakrar/)
 * (@rthakrar)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-groups-is-there-a-php-function-like-get_user_group/#post-2981092)
 * Thanks, [@itthinx](https://wordpress.org/support/users/itthinx/).
 * I’m not very good with PHP objects, so went for the ‘long but simple’ route.
 *     ```
       $userid = $current_user->ID;
   
       $user = new Groups_User( $userid );
       $groups = $user->__get( 'groups' );
   
       $gr1 = (get_object_vars($groups[1]));
       $gr2 = (get_object_vars($gr1[group]));
   
       if ($gr2 != "Team members" && $gr2 != "Associates")
       {
       	wp_die('This function is only for Team members and Associates.  Would you like to <a href="'.wp_logout_url( $redirect ).'">log in as another user</a>?');
       }
       ```
   
 * Thanks again,
 * R

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

The topic ‘[Plugin: Groups] Is there a PHP function like get_user_group()?’ 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/)

 * 2 replies
 * 2 participants
 * Last reply from: [rthakrar](https://wordpress.org/support/users/rthakrar/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-groups-is-there-a-php-function-like-get_user_group/#post-2981092)
 * Status: resolved