Drupal – Customized User Registration/Login/Forgot Password Page with Panel

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:

Advertisements

6 thoughts on “Drupal – Customized User Registration/Login/Forgot Password Page with Panel”

  1. For me it have to be in this style: (example show it for user_login)

    print drupal_render(drupal_get_form('user_login'));
    

    Like

  2. 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:

    /**
     * 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');
    }
    

    Above we redirect from /user/register to /register.

    Cheers,
    Tom

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s