Upgrade Your Drupal Skills

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

See Advanced Courses NAH, I know Enough

How to create groups within Drupal which can share nodes (and files) privately

Parent Feed: 

Say, for example, that you want to share content (like PDF files) with your clients. You don’t want them to be publicly available, because they are for your clients eyes only. You also don’t want clients looking at each other's files. This is where the Group module comes in. Here you can create different group types (such as client) with which you can create a separate group for each client you want to share files with. 

In this tutorial I will show you how to set up the group module which can be used to share nodes privately to a set group of users.

Setting the Privates Files Directory

If you only want to share nodes within a group you can ignore this part. If you want to share files you need to create a private files directory. Else users without the correct permissions would still be able to access the files by guessing the correct URL of the file and typing it in the address bar of their browser. Learn how to set up a private files directory for Drupal

Setting up the Group module

  • Install the Group module
  • Enable the Group node module
  • Navigate to Group > Group types
  • Click + Add group type
  • Name the group type. I will follow the example I mentioned above and name it Client
  • You can enable or disable Create a new revision when a group is modified as you please
  • Enabling The group creator automatically becomes a member can be helpful when you want users to create their own groups
  • It’s best to enable Group creator must complete their membership in case you have required fields on a users’ profile page
  • Enabling both Automatically configure an administrative role and Automatically assign this administrative role to group creators is very useful, because now you can create admin permissions within the group
  • Click Save group type
  • Next we need to create the content type that will be used to share within the groups. Navigate to Structure > Content types
  • Click + Add content type
  • I will name this content type File
  • You can fill in the settings in the tabs as you please
  • Click Save and manage fields
  • You can now add any fields you like, but as in the example I’m following I will add a File field. Click + Add field
  • Below Add a new field select File
  • Label the field File
  • Click Save and continue
  • Under Upload destination select Private Files (see the remark I made about this above)
  • Click Save field settings
  • In the next screen you can change the settings as you please. Below Allowed file extensions I’ll put pdf as I only want to share PDF files
  • I like to name the File directory something more generic like files
  • I also check Enable Description field because then you can label the fields with something that makes more sense instead of just showing the filename
  • Click Save settings
  • What we need to do next is to make nodes of this content type available to the Client group we’ve created. Navigate to Group > Group types > Client and click on the Content tab
  • Click on Install next to Group node (File)
  • You can leave the setting on the next screen as is. Click on Install plugin
  • To test if this works we need to create a Group (Client). Navigate to Groups
  • Click on + Add group
  • Enter any title and click on Create client and complete your membership
  • Enter any URL alias. This will be shown in the address bar of the browser when viewing the group and click on Save group and membership
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