Hi All,

I am looking for a module (or modules) that will help me achieve the following:

- An anonymous user completes details in a node
- On valid insertion of details they are taken to a page where they can create a user account on the site
- This account, once created is now associated with the node the user originally created as an anonymous user

In effect, this is the same as adding items to a shopping cart and then creating a user when you log out. I am guessing there must be something out there that can help me achieve this - can anyone help?

Much appreciated,

James

Comments

itangalo’s picture

I was going to say that this is more or less impossible, but as you point out there are e-commerce modules that acutally manages to do this.

The tricky part is that you have to (1) make sure that the anonymous user has a session cookie set, (2) use that cookie to set some kind of trace on the node that is created, and (3) use that trace to update the node once the user has created an account.

I don't know of any module that provides this functionality, other than Ubercart/Commerce. (I know that Flag has some similar functionality to keep flags through the login process, and I also know that this is associated with a bug that has caused considerable headache.)

I can think of four approaches to your problem:

1) Try to facilitate the functionality in Ubercart/Commerce. This is probably not such a good idea, since your users are creating nodes and not buying products.
2) Fake the functionality by actually having users entering node data on their user registration – which is then copied and saved into a node of its own. It's cheating, but may be worth investigating.
3) Use [Rules](http://nodeone.se/blogg/learn-rules-screencast-series-summed-up) or other mechanisms to set a field value when nodes are created, and use that to identify the node after account creation – and update the node. This is kind of hacky, but it too could be worth investigating.
4) Do a real module out of it, that solves the problem in the proper way – allowing you to separate different anonymous users as authors. This would be neat, but would also take a bit of time (and thinking).

Good luck!
//Johan Falk, NodeOne, Sweden

travelamp’s picture

Hi John,

Thank you for taking the time to reply - your suggestions are well received. I am thinking that maybe a module may be worth investing in - not just for us, but maybe the wider community. If anyone has any thoughts as to how such an approach could work that would be good.

Regards,

James

ethnovode’s picture

Hi,

I have the same problem. I'm currently using rules for D6 with this :
Event :
- After saving new content
Conditions :
- user has role -> anonymous
- content type is
Actions :
- Create user (using the cck email field)
- Define content user with the newly user just created
- Send email
- Show message

Now I need to find a way to check if the email address in the cck field is already used so i can add a condition for this.

Also there is a patch for email D5 I didn't look at : http://drupal.org/node/211754

Edit : Finally I used node limit number and unique field modules to do what i needed.

itangalo’s picture

In a perfect world such workarounds wouldn't be necessary, but in the world that we live in I'd say that this is a pretty good solution. Well done.

itangalo’s picture

I dug around in the cookie variables, and it seems that Drupal sets a session variable in $_COOKIE, with a hash key and probably hash value, such as
SESS33f899a20167004474bc0cc9bcf6368e => b2eb24db0d2542a72fea95815a45fdb5

This key, but not the value, is kept when you log in. In theory it would thus be possible to have the session key stored as a non-public value in nodes created by anonymous users -- and every time a user account is created all nodes with that session key gets the new account as author.

If anyone is tempted to go down this path, I strongly recommend investigating security implications of messing around with session variables -- I don't know anything about that. (I'm just curious!) One should of course also be aware of that sessions expire and are replaced, which means that any session keys older than a day or so are useless.

//Johan Falk, NodeOne
**
Drupal 7 introduction | The Views module | Drupal learning curve | Rules for Drupal 6 | Theming Drupal 6

g.paluch’s picture

I had similar problem and I solved using inline_registration module. The down side is that it is still in dev. But I was able get it work with logintoboggan and email authentication. I also used auto assign role module to change role from anonymous. And rules module for some custom behavior after node creation. As a result when visitor creates node new user account is created as well. The good think is you can setup where email and user name will show on your form. I noticed big change in user behavior when account creation fields (email and user name) are at the end of the form. Some users didn't even noticed that they opened new account.

http://drupal.org/project/inline_registration

itangalo’s picture

I took a little time to try to solve this problem "properly", and it is actually way doable.

I have not done a module that does all of the required stuff right out of the box, but I included some really useful parts of the functionality in a new project called Rules Bonus Pack: http://drupal.org/project/rb
If you use it together with the Session API module (http://drupal.org/project/session_api), you can store a session ID in a CCK field and then use that to identify any content a user has created when he/she creates an account.

Maybe I'll try to set up a complete feature that you can use as an example of how to do it, but I'm afraid there isn't one available now. :-/

//Johan Falk
**
Learn Drupal with Nodeone! Drupal 7 introduction | The Views module | Drupal learning curve | Rules for Drupal 6 | Theming Drupal 6

ollie222’s picture

I need to do exactly what I think you've achieved so I'll have a look at the projects you've linked to and see what I can do.

One query I have, have you made it do the post is not published and available until the user has clicked the activation link in the sign up email? There doesn't seem to be a event in rules for this.

If you can offer any further help it will be very welcome.

ideafarm’s picture

I have used the Inline Registration module to do this and it works great for me.