Title: Using groups at theme level
Last modified: August 22, 2016

---

# Using groups at theme level

 *  Resolved [Jack Dunstan](https://wordpress.org/support/users/batmanian/)
 * (@batmanian)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/using-groups-at-theme-level/)
 * Hi,
 * This is a similar to other questions, but I’m unable to lock down content at 
   theme level.
 * These examples work if the template files that are called don’t have php in them
 *     ```
       <?php
       $content = '[groups_member group="X"]';
       $content .=  get_template_part('permitted-content');
       $content .= '[/groups_member]';
       echo do_shortcode( $content );
       ?>
       ```
   
 * This doesn’t work either
 *     ```
       <?php
       echo do_shortcode( '[groups_member group="X"]'
       . get_template_part('permitted-content') .
       '[/groups_member]' );
       ?>
       ```
   
 * I’m getting all content in the files being executed regardless of the groups 
   permissions.
    Any ideas?
 * [https://wordpress.org/plugins/groups/](https://wordpress.org/plugins/groups/)

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

 *  Thread Starter [Jack Dunstan](https://wordpress.org/support/users/batmanian/)
 * (@batmanian)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/using-groups-at-theme-level/#post-5798344)
 * Worked it out.
 * This is how it can be done.
 *     ```
       <?php
           $user_id = get_current_user_id();
           $group = Groups_Group::read_by_name( 'Your Group Name' );
           if ( Groups_User_Group::read( $user_id, $group->group_id ) ) {
              get_template_part('some-php-file-in-your-theme-directory');
           } else {
              get_template_part('another-php-file-in-your-theme-directory');
           }
       ?>
       ```
   
 *  [Rakesh Rathore](https://wordpress.org/support/users/rakesh-rathore/)
 * (@rakesh-rathore)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/using-groups-at-theme-level/#post-5798483)
 * Its Working
    Thanks 🙂

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

The topic ‘Using groups at theme level’ 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/)

## Tags

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

 * 2 replies
 * 2 participants
 * Last reply from: [Rakesh Rathore](https://wordpress.org/support/users/rakesh-rathore/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/using-groups-at-theme-level/#post-5798483)
 * Status: resolved