5

I want to create a custom login and register page. I want both forms to show on the frontpage in the content area of my template above each other and not on separate nodes. Also, I would like to try to reuse the already existing code for validation of the forms.

I have looked around and found different ways to achieve this so I wonder what's the best way to do this..custom block, module or inside template or...?

Links to content or particular examples would be appreciated.

1
  • You could create them as blocks and places the blocks where you want.
    – antgiant
    Mar 25 '11 at 15:22
8
drupal_get_form('user_login');

And

drupal_get_form('user_register_form');

Will return the form for you and will deal with all the form stuff that needs to be dealt with. You just need to print whatever is returned by that function out and it should work.

Note: You did not specify the Drupal version, when using 7, drupal_get_form() returns an array which you need to pass through drupal_render() first to get a string that you can print.

3
  • Ok Thanks. do you recommend to use it in the theme or as a module?
    – grm
    Mar 13 '11 at 18:51
  • Depends. Maybe not directly in a template file, but you could implement a preprocess function, call it there and then just output the $variable in the template file. It can be in the theme though.
    – Berdir
    Mar 13 '11 at 18:58
  • Ok. Will give it a try. Btw: I found a module called LoginToboggan that has similar functionality. just for the record. Appreciate your help.
    – grm
    Mar 13 '11 at 19:08
1

Below are the name suggestions for tpl files used for user login, password reset, and user registration.

page-user-login.tpl.php page-user-password.tpl.php page-user-register.tpl.php

in the above you can use drupal_get_form('user_login'), drupal_get_form('user_pass'), drupal_get_form('user_register') to display the form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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