Override login form

anthrocreative - July 30, 2008 - 19:29

I'm relatively new to Drupal, but very experienced with PHP. I'm attempting to implement a custom login form in a custom theme and I've done a ton of searches trying to figure out how. A lot of the things I've found apply to Drupal 4.x/5.x. The things that apply to Drupal 6 don't give me a complete picture on the subject.

So, here's what I've tried:

- I can alter the form with a phptemplate_user_login() function in template.php, but that doesn't seem to get called. I've also tried naming this function theme_user_login_form(), theme_user_login(), and other variations. Even when I register the function (see below) it doesn't get called.

- I've also tried registering the above function using the themename_theme() function, returning the requisite array. That function gets called.

- I've tried using phptemplate_form_alter(), but that doesn't get called either.

I've also tried using various block template names to no avail.

I'm trying to modify the login form to add some classes, some javascript and an extra input field. Any help on the best way to approach this would be very appreciated!

(and related to that, same question above about polls too -- how can I customize the form output?)

-- Shane

By registering an

ckng - July 31, 2008 - 05:40

By registering an unregistered form
Note: must use your theme name.

function yourtheme_theme() {
  return array(
    'user_login' => array(
      'arguments' => array('form' => NULL),
    ),
  );
}

function yourtheme_user_login($form) {
  // Do whatever you want with the form
}

CK Ng | myFineJob.com
consultation • web design & development • content development • site domain, hosting & maintenance • software design & development

A little more info please

piersg - December 2, 2008 - 01:40

Hi ckng

Thanks for your comments. Could you just clarify: do these functions go in template.php? do we need to use _phptemplate_callback any more? Do we need the file user_login.tpl.php any more?

This all worked beautifully in D5, why do they have to keep breaking things when the version updates?!

 
 

Drupal is a registered trademark of Dries Buytaert.