phpdrupaldrupal-fapidrupal-alter

Registration during content creation in Drupal?


Is there an easy way to allow a user to register as he creates content type. E.g. Let's say there is a content type called "listing". When the user clicks to on a link to create it, and he's not logged in, I want a "register" box to appear ABOVE THE CONTENT CREATION area, where the user can enter his normal registration details. Is this possible?


Solution

  • You should be able to do this with hook_form_alter. So you can run a check if the node is being created (no nid set yet) and the user is no logged in, and then just add a fieldset with the info needed to create an account. You need to add a validation and submit handler as well to check the data and create the actual user.

    All you need to do then, is to pair the node to the new user, but that should be possible in the submit handler where you create the user.