Customize User Login, Register and Forgot Password Page in Drupal 7

Did you ever want to customize your registration or login page on Drupal 7, but did not know how? Customizing these pages by adding new text or changing theme is not a difficult task.

To help you out with that, I have compiled some simple steps to customize your registration or login page. All that you need to do is to add the following code :


  1. In the first step of customization, you need to implement hook_theme in your module file.
    function yourmodule_theme() {
          $theme = array(
          'user_login' => array(
          'template' => 'user_login',
          'render element' => 'form',
         'path' => drupal_get_path('module', 'yourmodule') . '/templates'
        'user_pass' => array(
          'template' => 'user_pass',
          'render element' => 'form',
        'path' => drupal_get_path('theme', 'yourmodule') . '/templates'
        'user_register' => array(
          'template' => 'user_register',
          'render element' => 'form',
          'path' => drupal_get_path('theme', 'yourmodule') . '/templates'
      return $theme;
  2. Now that you have implemented hook theme in module file, the next step is to implement three pre-process functions. These functions are used if module needs to override or you want to add something in theme pre-processing.
    function yourmodule_preprocess_user_login(&$vars) {
      $vars['intro_text'] = t('This is my awesome login form');
    function yourmodule_preprocess_user_register_form(&$vars)  {
      $vars['intro_text'] = t('This is my super awesome reg form');
    function yourmodule_preprocess_user_pass(&$vars) {
      $vars['intro_text'] = t('This is my super awesome request new password form');
  3. In the third step, you need to create following template files for login/register/forgot password.
    1. user_login.tpl.php
    2. user_register.tpl.php
    3. user_pass.tpl.php
  4. Now paste the following code into user_login.tpl.php. Also, don’t forget to modify user_register.tpl.php and user_pass.tpl.php template files accordingly.
    <?php print render($intro_text); ?></p>
    <div class="yourtheme-user-login-form-wrapper">
      <?php print drupal_render_children($form) ?>
  5. Finally, clear your website’s cache and you are done!

Now your login page will contain new intro text This is my awesome login form. Customization of registration page in Drupal 7 is not difficult and if you follow above mentioned tips, you can design an amazing registration / login / forgot password page according to your audience.

Versha Gupta


Versha is a Software Developer at LoginRadius. She graduated with a Bachelor of Technology Degree in Computer Science Engineering. She enjoys gaming, playing chess and listening music.

Leave a Reply