Alter User Login form and Password Reset form

Public

Alter the User Login form and Password reset form by implementing hook_theme and preprocess hook in templete.php of your theme.

</> CopyGet raw version
php
  1. <?php
  2. function THEMENAME_theme() {
  3. $items = array();
  4.  
  5. $items['user_login'] = array(
  6. 'render element' => 'form',
  7. 'path' => drupal_get_path('theme', 'THEMENAME'),
  8. 'template' => 'user-login',
  9. 'title' => 'log in',
  10. 'preprocess functions' => array(
  11. 'THEMENAME_preprocess_user_login'
  12. ),
  13. );
  14.  
  15. $items['user_pass'] = array(
  16. 'render element' => 'form',
  17. 'path' => drupal_get_path('theme', 'THEMENAME'),
  18. 'template' => 'user-pass',
  19. 'preprocess functions' => array(
  20. 'THEMENAME_preprocess_user_pass'
  21. ),
  22. );
  23. return $items;
  24. }
  25.  
  26. function THEMENAME_preprocess_user_login(&$vars) {
  27. //print_r($vars);
  28. //alter the login form here
  29. }
  30.  
  31. function THEMENAME_preprocess_user_pass(&$vars) {
  32. // alter the reset password form here
  33. }
  34.  
  35. //Create the user-login.tpl.php and user-pass.tpl.php template in your theme