By Jerimee on
I have a simple form that loads volunteers into a database. At the same time that someone signs up to volunteer via this form I would like to sign them up for the Drupal website associated with the project.
What php can I use to register a user? The only data required is "Username" and "Email," how do I get those two pieces of data into the proper user registration function?
Comments
was my question stupid?
Should I rephrase it? Am I thinking about the problem the wrong way?
post to user-register
This is the relevant code at mysite/admin/user/user/create, but I'm not clear on what happens when you post to "user-register." User-register is a function within the Drupal core (probably user module), but how do I access that function from outside Drupal (i.e. my own form script)?
I can see 2 ways of
I can see 2 ways of approaching this:
1. Convert your custom PHP page/form into a page/node on the Drupal site. You would then need to use Drupal's Forms API to create and process the form (see the relevant links here http://api.drupal.org/api/5). Actually you might need to do this in a custom module http://drupal.org/node/508. I'm not sure whether you can get forms to work properly if they are embedded in a page.
2. Include the following at a relevant point in your PHP file:
This gives you full access to Drupal from your script. You could then call user_register() having populated $form_id and $form_values appropriately. You could even call http://api.drupal.org/api/function/user_save/5 directly, but be aware that this could be open to abuse as it would bypass security checks etc. Also if the username or email address is not unique then you may get various errors.
Alternatively Drupal does support distributed authentication so that might be another way to access the account creation functionality. Actually, that's probably a much better way of doing it! OpenID is in Drupal 6 core http://drupal.org/node/152893, and available as a module in Drupal 5 http://drupal.org/project/openid.
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
gpk, thank you for the response!
I really needed the help. Now I can get back to work.
While I am distrustful of things I do not understand, I'll try OpenID since you recommend it. I'm using Drupal 5, so hopefully the module aint' buggy.
If I run into a wall on OpenID, I'll try including the drupal_bootstrap. Thank you for showing me how to do this.
OpenID
I tried OpenID as a solution, but after playing with it a bit I decided I don't have enough familiarity with (or trust in) OpenID to use that as the solution.
It just doesn't seem user friendly enough. It seems to require people to login twice (eliminating the convenience), and a duplicate username causes it to fail.
I'm going to try the drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL) method now.