I have written a custom module, inside which I would like to create a custom user login block with custom theme applied. Now my question is "Inside my custom module, how do I get the user login form?"

1 Answer 1


You can use drupal_get_form() to get the rendered form:

$form = drupal_get_form('user_login');

To override the default theme for the form have a look at Theming the contact form in Drupal 6 which goes through all the necessary steps very thoroughly.

  • I am able to retrieve the user login form, but how do I alter the form? For example, I would like to alter the value of $form["links"], how do I do that?
    – Vivek
    Feb 8, 2012 at 12:16
  • You would need to do that in hook_form_alter(), which would be called before the $form is returned to you in drupal_get_form(). The documentation should make it a bit more obvious what to do
    – Clive
    Feb 8, 2012 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.