Update @ 2012-12-30: Here is much simpler approach proposed by tombehets. Thanks =D
/** * Implements hook_menu_alter(). */ function mymodule_menu_alter(&$items) { //redirect user/register to register, our custom panel. $items['user/register']['page callback'] = 'drupal_goto'; $items['user/register']['page arguments'] = array('register'); }
–
Panels is a very useful module in Drupal which helps us to customized page view with specific layout. Unfortunately, it does not support the User Login, User Registration and Forgot Password pages.
Luckily, I found a simple workaround on Google. The idea is just creating a custom panel page as usual and add a custom panel pane with the desired form as follow.
<?php // Drupal Login Form print drupal_get_form('user_login'); // Drupal Registration Form print drupal_get_form('user_register'); // Drupal Forgot Password Form module_load_include('inc', 'user', 'user.pages'); print drupal_get_form('user_pass'); ?>
Then we could add the following tpl.php in the theme folder and redirect to out newly created custom pages.
Drupal 6
- page-user-login.tpl.php
- page-user-register.tpl.php
- page-user-password.tpl.php
Drupal 7
- page--user--login.tpl.php
- page--user--register.tpl.php
- page--user--password.tpl.php
Inside the above tpl.php, redirect to the correct URL using druapl_goto().
<?php // Redirect to the custom login page drupal_goto('user-registration'); ?>
Done =)
Reference:
For me it have to be in this style: (example show it for user_login)
LikeLike
Thanks for your comment. Are you working on D7?
The example in this article is on D6. I didn’t try it on D7.
LikeLike
Hey, I would propose a cleaner way to redirect.
Instead of a drupal_goto called from the theme layer, alter the menu, so the theme layer is skipped.
Here an example:
Above we redirect from /user/register to /register.
Cheers,
Tom
LikeLike
Thanks for your great solution. i have updated this post. =D
LikeLike
Almost works, need to use double hyphens in your template files though (e.g. page--user--register.tpl)
LikeLike
Thanks for your comment~ The double hyphens are for Drupal 7. Post updated. =)
LikeLike