views:

31

answers:

2

I have a default user registration form that cannot change. However my boss wants a second registration form that is laid out differently than the first. I am new to Drupal so some explanation would be great.

Thank you in advance

+1  A: 

If you create a custom module you can define a path for the second menu item using hook_menu().

function user_menu() {
  $items['user/custom_register'] = array(
   'title' => 'Create new account',
   'page callback' => 'drupal_get_form',
   'page arguments' => array('user_register'),
   'access callback' => 'user_register_access',
   'type' => MENU_LOCAL_TASK,
   'file' => 'user.pages.inc',
   );
   return $items;
 }

Of course this will not look any different to your exsisting form, it will just be a different path.

To customize the form you have a coulpe of options, you could use hook_form_alter() and check the path. Or you could change the page arguments argument above to something which called user_register and customizes the output.

Jeremy French
+1  A: 

Let me save you some time, as I just solved this on a few sites. Check out the login forms here:

This is the basic user login form. I am overriding it by telling Drupal to use a custom tpl file to load this page, and in the TPL, I am added additional elements and adding to style.css.

There is a write up on how to do that here:

http://www.lullabot.com/articles/hacking-phptemplate

Halfway down it shows you how to work with template.php to define new tpl pages for specific paths.

What you want to do is tell it when 'user' or 'user/register' is loaded, use a tpl file (you can name it). Then, you can work with the preprocessor functions and add to the page, like change the into words at the top, or remove certain form elements. The benefit is you can add all you want to the user registration form through the core Profile module or other modules, and they will still be presented here.

It will save you a lot of time this way instead of try to reinvent the user login process with your own module (I've tried that too).

Kevin