1

I have 2 drupal roles. Let's say a teacher and student.

A teacher should be able to:

  1. Create student account.
  2. Create new nodes.

Student should be able to:

  1. Edit and view ALL nodes created by the teacher who has created his account.

Since it involves mapping of users, I've used the subuser module

I have checked the content access and node access modules as well but they doesn't let me map teacher's content to his student (sub-user). These modules require me to grant permission for individual nodes created by teacher and does not apply permissions automatically to all content created by the teacher.

How do I make all sub-users automatically get edit permission to all content created by parent user?

PS: My actual problem is much more complicated with multiple seller roles and integrating with payment methods. However a solution to this simple case will guide me to go about the problem.

1 Answer 1

3

I think you already solved this yourself but searching the same issue I ended up on this post. Since I found a solution I will post it here for all other people running in to this problem.

The solution is in combining the modules subuser and user relationships and rules.

  • Subuser gives other users the right to add new users. These users are related to each other with the relationship module but there is no link between their nodes.
  • To get the link between content of the users I used the user relationship module. This module let's you set up relationships as friend, coworker or co-editor or whatever name you want to give it. These relationships can give one way or two way permissions to update, view or delete each others nodes.
  • Normally you would have to go to a users page and request the relationship with the user but with rules it's possible to set a relationship when a new user is created.

So what steps to take. First enable all modules. For the user relationship you have to enable the main module but also the User Relationship UI and the User Relationship Rules module. Now go to the relationship module admin/config/people/relationships and create a relationship with the name "friends" (or whatever name you want). At the share content tab make sure that the content type you want to share is selected.

Now go to roles admin/people/permissions/roles and create a new role with the name "friends" (so the same as your relationship, just because it's the most clear).

Now go to permissions admin/people/permissions and set the User Relationship permissions as you want. Make sure that Grant view permission to related users and Grant update permission to related users is set in the right way to the roles you use. So if you want the subuser(friend) to be able to see and edit the parents content make sure the permissions are on for him. Also make sure he has the right to get the friends relationship. Also make sure the parent has all these rights as well.

Now go to the parents user page and go to the share content part, set it up so that the friend is able to update and view content.

When all this is done it's time to go to Rules in rules it's possible to create a rule that says: - If User Created - And Role is Friend - Request Relationship (Friend) - Auto Approve Relationship

Now when the parent creates a subuser the subuser will be able to edit and view its parents nodes. For the parent it is still possible to give his Friends a per node based access to it's nodes. So on default all nodes are shared but the parent can edit this per node.

I hope this is clear enough I did my best, but please let me know if there are any unclear parts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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