I have a secondary system handling user authentication, but I would like to use the user creation code from that system instead of Drupal. I want to redirect the Drupal user creation to the secondary system instead.

I already have my own user creation page, so I don't want to do a form_alter on Drupals user creation, I'd rather just send the user to my creation page instead.

How do I redirect user/register to my code instead of Drupal?

  • Ended up modifying @BetaRide suggestion by using drupal_goto inside user_register_form_alter. Not sure if it's the best option, but it works for me.
    – TomCDona
    Dec 21, 2011 at 18:05

2 Answers 2


Roling your own user registration and authentication requires a number of steps. I try to eyplain them.

Calling yourmodule_form_user_register_form_alter(&$form, &$form_state, $form_id) would be a good idea. Actually you have to alter only the submission call back and may be the validation call back. You can have a look at the last lines of user_register_form how this is done in drupal core.

To make sure the users can login. It's possible to include an external authentication service. Have a look at user_login_default_validators for this.

What is most important for you, that at the end of the login procedure you have to have a valid drupal user object. I'd recommend to have parallel external and drupal users. Probably do the authentication on your external service but let drupal load the corresponding drupal user once this was successful.

This gives you basic working system. Next steps would be to handle password change and one time password recovery links in a correct way.

  • I already have the authentication working against my system, so existing users of my system can already login via the drupal user/password blocks. I just want to send them to my user creation page instead of drupals.
    – TomCDona
    Dec 21, 2011 at 16:44
  • something like this: function yourmodule_form_user_register_form_alter(&$form, &$form_state, $form_id) { $form["#action"] = "path/to/your/custom/registration/form"; } Dec 21, 2011 at 16:48

This might work:

function yourmodule_menu() {
  $items["user/register"] = array(
    "type" => MENU_CALLBACK,
    "page callback" => "yourmodule_user_register_override"
  return $items;

function yourmodule_user_register_override() {

Also, you can create a preprocess function in your theme's template.php file like this:

function YOURTHEME_preprocess_page(&$vars) {
  if(arg(0) == "user" && arg(1) == "register") {

Or, as @BetaRide said:

function yourmodule_form_user_register_form_alter(&$form, &$form_state, $form_id) {
  $form["#action"] = "path/to/your/custom/registration/form";
  • Doesn't seem to do it. $items['user/register'] = array( 'title' => 'Custom User Registration', 'type' => MENU_CALLBACK, 'page callback' => 'drupal_get_form', 'page arguments' => array('custom_user_register'), );
    – TomCDona
    Dec 21, 2011 at 16:28
  • sorry, I forgot to add the return $items in the hook_menu funciton. Also, menu items are cached and you need to clear caches for the new settings to be visible. Dec 21, 2011 at 16:43
  • also, as @BetaRide said, you should have valid users for the drupal system as well Dec 21, 2011 at 16:45
  • Tried the $form['#action'] but for some reason it's not redirecting. I'm also hooked into _form_user_login_block_alter and _form_user_login_alter. Could they be interferring somehow?
    – TomCDona
    Dec 21, 2011 at 17:54
  • $form['#action'] is working but it's not the desired function. I want to redirect to my user creation form, not send user creation details to my code on form submit. I don't want to use drupals user_register form at all, I want to use my own
    – TomCDona
    Dec 21, 2011 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.