Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

How to Use the Drupal Group Module

Parent Feed: 
How to Use the Drupal Group Module

Group is an extremely powerful Drupal 8 module that allows you to create groups of users with shared content and permissions. 

It's easy to imagine that this module will replace Organic Groups, and become the default choice for social sites in Drupal 8.

In this tutorial, I'm going to explain how you can use the new Group module to organize your site's users.

Step #1. Setting up Groups

Here's how to get started:

  • Download and enable the Group module. Enable all 3 submodules.
  • You will see a message asking you to rebuild the permissions because Group does change the way that the permissions work. Click this link and rebuild the permissions.

rebuild permissions

Now we can start to set up our groups. One key thing to know about Group is that it has a group type feature. This is very similar to the relationship between content types and nodes.

  • Click the Groups icon in the admin menu.
  • Select the Group types tab:

Overview of the group types

In this example, we're going to be building a news site with different editor levels. We will be making one group for each team. 

  • Click "Add group type" and set up the groups, as in the image below:

groups-module

As with content types, you can create fields for the group types. For example, you could use these fields to create a profile of each team with its logo, location and more.

Step #2. Connect the group types to content

Now we're going to connect our groups to content types. This will allow us to use the Group module for extra permissions. In this example, I'm going to connect the Basic Pages content type to our groups.

  • From the Group Types page, go to the "Manage fields" dropdown and choose "Set available content": 

available-content

  • Click "Install" for "Group node (Basic page)".
  • You will now see a confirmation screen. Click "Install plugin".

plugin

Step #3. Add the groups

Now we can start to add the groups.

  • Go to Groups > Add group
  • Choose one of the group types you have set up.

content group type

  • Give the group a name. In this case, I'll call the group "Basic Page Writers".
  • Save the page and this will take you to the group summary page. From here you can view the group's details, members, and content.

setting up a basic page writers group

From this page, you can add some members to test the groups:

  • Click the "Members" tab.

The members tab in groups

  • Click "Add member".
  • You can now add existing users to this group:

add members to groups

You can also add some content from this main group page.

  • Click the "Node" tab.
  • Because we choose "Group node (Basic page)" in Step 2, you can now add basic page content to this group by clicking "Create node".

add nodes to groups

Find out more

This presentation on the Group module from DrupalCamp London is excellent:

Summary

We've only just scratched the surface of the Group module in this tutorial. It's already one of the best modules I've seen for Drupal 8 and it's clearly a very strong option for anyone wanting group functionality. If you have any requests for further Group tutorials, please let us know in the comments.


About the author

Daniel is a web designer from UK, who's a friendly and helpful part of the support team here at OSTraining.

Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web