I'm creating a collection manager for movies and books in Drupal 8. Now I have a content type called "collection" and one that is called "Movie". The collection is just a collection of different movies. Now I'm searching for a way that a user can give another user access to his collections and movies.

How can I achieve this in my module?


Your question looks like a perfect fit for the Group module, which can be used to create collections of content (nodes) that can be accessed by sets of users and with variations of access levels, such as none or read only.

Have a look at the answer to What are the alternatives for the Organic groups module? for a brief introduction to the Group module.

For this specific question, here is a blueprint of how it could be used/configured:

  • Group Type: Collections
  • Group Roles (refer to "What are the various roles supported by the Group module?" for more details):
    • Group Owner
    • Group Fans (or whatever fits), used for those who have access to a selected collection.
  • Groups (adapt the group titles to fit your collection names):
    • Collection 1 of user A.
    • Collection 2 of user A.
    • Collection 1 of user B.
    • Collection 2 of user B.
    • Collection 3 of user B.
    • ...
    • Collection I of user X.
  • If a user creates a new group, then automatically assign role "Group Owner"-role to the user who created the group.
  • Group permissions: grant permission to the user with role "Group Owner" to perform actions like "Add members" or "Invite members to join".

To use the Group module from within a custom module, start from its Development guide and/or have a look at its API for D7 or API for D8.


PS: Even though this question is tagged for D8, this answer applies for either D7 or D8 ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.