views:

202

answers:

2

I'm presently building (at this point, prototyping is a better term) a paid subscription site using Drupal. After searching through the Drupal modules - I haven't been able to find anything that will allow me to create a new Drupal account once the user has visited my landing page, decided they want to subscribe, and provided their valid credit card information. Ideally, I'd like to redirect them to the subscription site with a newly created account once their credit card info has been validated.

It's quite possible that the solution is very simple and I'm just not thinking out of the box...is anyone familiar with a module or a methodology for remotely creating a user account with Drupal? OpenID is a possibility but I would like to give the user a little more freedom in selecting their username.

+1  A: 

Why not extend Drupal's registration form with some extra fields and validation functions?

ceejayoz
+1  A: 

You could have a hook, function, or build an xml-rpc interface to a function that created a new user account after the user has entered their details.

For example, on the form that they fill out, you could have in the _submit of the form:

formname_sumbit($form, &$form_state) {
 // Do form stuff here

// Now do user_save stuff
$password = user_password();
$mail = $form_state['values']['email_address'];
// Use blank account object as we are creating a new account
$account = array();

$properties = array('name' => 'someusername', 'pass' => $password, 'mail' => $mail, $roles => array('authenticated user', 'some other role'));
$this_user = user_save($account, $properties);

}

That should take care of creating the user. I'm not sure about how to login them automatically, but a global $user; $user = $this_user; might work. The user should be notified of their new account via email by the user_save function, but you might want to let them know with a drupal_set_message as well.

http://api.drupal.org/api/function/user%5Fsave/6

cam8001