Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top