Customising the user registration form
description
These snippets allow you to override the default user registration layout using a custom user_register.tpl.php.
If you want to customise the full page layout, click through to the Customising the login, registration and request password full page layout handbook page.
step 1 of 2
In a text editor like notepad.exe, create a file called template.php using the the following snippet. If you already have a template.php file, simply add it to your existing one (remembering to omit the opening and closing PHP tags if you're adding it to an existing template.php file, i.e. <?php and ?).
<?php
/**
* This snippet catches the default login form and looks for an
* user_register.tpl.php file in the theme folder
*/
function phptemplate_user_register($form) {
return _phptemplate_callback('user_register', array('form' => $form));
}
?>step 2 of 2
- In a text editor create a new text file and paste the following snippet into it. Save the file with the filename user_register.tpl.php
- Edit the style sheet classes and content to suit
- Upload your edited user_register.tpl.php to your active theme folder
For use with Drupal 4.7.x
<div class="registration_form">
<p>Extra instructions or content can go here, just above the registration form</p>
<?php
print_r(form_render($form)); // this displays the login form.
?>
<p>Extra instructions or content can go here, just below the registration form</p>
</div>For use with Drupal 5.x
<div class="registration_form"><p>Extra instructions or content can go here, just above the registration form</p>
<?php
print_r(drupal_render($form)); // this displays the login form.
?>
<p>Extra instructions or content can go here, just below the registration form</p>
</div>Style sheet reference
For controlling how your registration form looks using your style sheet, this is what the rendered registration form HTML and class names are by default:
<form action="/user/register" method="post" id="user-register">
<div class="form-item">
<label for="edit-name">Username: <span class="form-required" title="This field is required.">*</span></label>
<input type="text" maxlength="60" name="name" id="edit-name" size="60" value="" class="form-text required" />
<div class="description">Your preferred username; punctuation is not allowed except for periods, hyphens, and underscores.</div>
</div>
<div class="form-item">
<label for="edit-mail">E-mail address: <span class="form-required" title="This field is required.">*</span></label>
<input type="text" maxlength="64" name="mail" id="edit-mail" size="60" value="" class="form-text required" />
<div class="description">A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.</div>
</div>
<input type="hidden" name="form_id" id="edit-user-register" value="user_register" />
<input type="submit" name="op" id="edit-submit" value="Create new account" class="form-submit" />notes
- If you have an even more advanced snippet that has been tested, please add a child page to this handbook page
- This snippet was tested with Drupal 5.x (June 24th 2007) by Dublin Drupaller (Note: If you have the locale.module enabled you may need to refresh your search_index by editing any text string related to the user page before your changes take effect, such as 'password'. )
- More advanced snippets to follow
