Monday 22 March 2010

How to change User Login form

first take view source of user login page and find form_id which is user_login.
write the following functions in your template.php file which you will find under your theme folder.
here I am using garland theme.

function garland_theme()
{
'user_login' => array(
'template' => 'user-login',
'arguments' => array('form' => NULL),
),

);
}

function garland_preprocess_user_login(&$vars)
{
/*print '

';
   print_r($vars);
   print '
';*/

$tempVar = $vars['form'];

$tempVar['name']['#title'] = 'User Name';
$tempVar['submit']['#value'] = 'Log In';

$vars['username'] = drupal_render($tempVar['name']);
$vars['userpass'] = drupal_render($tempVar['pass']);
$vars['submit_button'] = drupal_render($tempVar['submit']);
$vars['tempForm'] = drupal_render($tempVar);


}

Now create  user-login.tpl.php and paste the below code into it and done.

<div id="registration_form">
  <div class="field">
    <?php
      print $username;
    ?>   
  </div>
  <div class="field">
    <?php
     print $userpass;
    ?>   
  </div>
  <div class="field">
    <?php
        echo $tempForm;       
        print $submit_button;
      ?>
    </div>
  </div>
</div>

Note: do not forget to clear cache of drupal from Administer -> Site Configuration -> Performance

No comments:

Post a Comment