I have a node type on my site that I want to allow anonymous users to fill out and save, but not access until they have registered and/or logged in.

Here's the basic functionality I want to offer the user:

- After an anonymous user saves the node, they are redirected to the drupal login page with an option to register for a new account.
- Registration or login must use the core drupal registration and login modules.
- After registration or login, the saved node is then attributed to the user's account.

The idea is to let an anonymous user create a node, but not access the node until they have registered and/or logged in. The main part I need help with is redirecting the user to login/register and then attributing the node they created to the account they eventually register and/or log in with.

I did some experimenting with rules to try to get this to work, but I couldn't figure it out.

I've seen the Inline Registration module (http://drupal.org/project/inline_registration), but it doesn't have the crucial feature of letting the user fill out the node form BEFORE they are prompted to create an account.

If anyone has an idea how to accomplish this that would be awesome! Or if you know of a module or combo of modules that would get me on my way. Thanks!

Comments

Codeblind’s picture

Create a content type with needed CCK fields to use as your form.

Use something like Content Access http://drupal.org/project/content_access to grant Anonymous user Create but not View privileges. In theory, once they submit the form, it should try to take them to the node view page, which is restricted, and should reroute them to the user registration form. If not, you can set your Access Denied page to the register form.

davedg629’s picture

Thanks for the response codeblind.

The only issue I see with that solution is that the node they create would not be associated with their user account after they register. It would just be a node created by an anonymous user.

So I guess I would need a way to tie that node to the account they create.

Thanks again, I had not thought of this and it gives me something to think about.

Codeblind’s picture

You could set a session variable with the nid and when a new user registers, update said node's author information.

davedg629’s picture

I found one post about this, but it seems to be about drupal 5 and the guy doesn't really have it figured out - http://drupal.org/node/350026

Does anyone know of some resources I can check out that will help me accomplish this for drupal 6? I know basic php and can learn stuff fairly easily if I have some documentation/resources to go from.

Codeblind’s picture

I think the easiest way to do it would be to require an email address on the form. Then, when a user registers, use their email address as a key to update the node table.

GBain22’s picture

I need the exact same functionality - would be interested in that email updated functionality - sounds like a good way to go about it. How would you go about creating such a script that could look for the email address and assign it to the user?

Cheers,
Garry.

flacoman91’s picture

if you find out how to do this, could you please share?

I'm trying to mimic the same functionality by having a modal popup if users aren't logged in or registered.

Here's an example functionality I'm trying to accomplish from yelp.com.
If you go to the site as an unregistered user, select a business, click write a review.

Then click Sign Up and post.

Once User clicks signup and post and a modal overlay appears that pulls the user_register form.
Once that's done, then publish the node and tie the user to that session.

I'm still stuck because I don't know the form api well enough to create a button that opens a modal form.

flacoman91’s picture

Well, not exactly like this, but close.

What I did was:
Set user permissions to allow anonymous users to create the content type you want.
if the userid is 0 (not logged in)
I overrided the node edit form for the content type I wanted to prevent them from hitting publish/submit.
(override the submit button) Create a new button to pop the registration form in a modal window.

I also used jquery to save off the form data in the user's browser in cookies I set.

Once the user's logged in they are redirected to the node edit form and jquery repopulates the form with the saved off data.

now that they're logged in, the standard form buttons are there and they can hit publish.

flacoman91’s picture

I created a sandbox project for d6 to do this

http://drupal.org/sandbox/flacoman91/1511724

here's a demo site I made to demonstrate this process.
http://d6.dinhdesigns.com/node/add

Stasko2’s picture

Great work, is it possible to achieve the same effect in Drupal 7?