1

I am building 500 nodes of same type with different info in them. When I am finished, I want to give each user that will register 1 node that is already in the system, and only that user can edit or add data to that particular node.

Any suggestions about how to do so?

  • 4
    Why does it need to be a node? Your question sounds like you need user profiles, not nodes... – marcvangend Nov 14 '11 at 20:44
1

I would setup all those nodes as a particular content type and author. Then you could give those users a role once they register that allows them to edit their own nodes for said content type. Then you will of course need some custom code that runs at that time to find one of those nodes and change the author to the registered user so that they can edit it. Probably could the last part with Rules but you might need to use custom php to find a node and change the author.

|improve this answer|||||
1

I'd make a module that implements hook_user_insert(), and this module would allocate a special node whenever a user was created. I'd then make sure that the permission system never allowed users to create that node type, or edit or delete, or whatever you don't want users to do with their node.

I might also use Entity Reference module, or Node Reference, to attach the node to the user entity.

|improve this answer|||||
0

It may be possible to coming Node Access module with Rules module to create a conditional action where, on registration, a user is assigned to a node. I haven't done this and would suggest reading documentation before going head first at it.

|improve this answer|||||
0

Start with implementing "give each user that will register 1 node" (as in your question): simply change the node author to the user you want to give a specific node to.

Combine this with the Rules module by using Rules Event System > Drupal is initializing, and with a Rules Condition related to the URL for the edit operation. The rule you'd need is a variation of the rule I included (in export format) in my answer to the question about How to restrict access to a node via node/12 and allow access via a path like content/sometitle?

These are the changes to that rule to make it work this case also:

  • The paths containing node should be extended by adding /edit at the end.
  • Add a (1ste) Rules Condition like "If NOT (Author id matches the uid of the currently logged in user)".
  • Add a (2nd) Rules Condition to check if the content type to be edited matches the content type you want to use for this.
  • If you also want to continue to allow special roles to edit such nods (eg an administrator), add a (3rd) Rules Condition to check if the currently logged in user does NOT have that role.
  • Change the "Message" in the Rules Action to something that fits your case.
  • Modify the Rules Action to fit your own requirements, e.g. to issue a redirect to some 'help page' with more details about this.

Should you also want to impose similar validations to 'delete' such nodes (which is not what your question currently says however ...), then create another rule in which you use a similar approach as for 'edit' (as described above), just replace all 'edit' by 'delete'.

Video tutorials

If you're not familiar (enough/yet) with Rules, checkout the 32 (!!!) great, and free, video tutorials Learn the Rules framework.

|improve this answer|||||

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.