I want to modify login block!Where can I see login block ?

I am using danland theme in drupal 7 site. So far I have walked through sites/all/themes/page.tpl.php file, node.tpl.php and template.php file, but I didn't find.

Can anyone help me in this ?

Thanks in advance.

enter image description here

  • goto admin/structure/blocks here you will find login block placed in region.
    – WaQaR Ali
    Sep 29, 2015 at 5:50
  • @WaQaR: I want to modify the code, so i want to go through root of the files
    – neethu
    Sep 29, 2015 at 5:52
  • What do you want to modify? please edit and update your question for better understanding.
    – WaQaR Ali
    Sep 29, 2015 at 6:01

1 Answer 1


Here are the steps for customizing login block available in Drupal.

1) Go to your template.php file for the theme you're working on. Should be in the root of the theme folder for your theme

2) Now check for the below mentioned function in your template.php file. if its not exist then create it and if its exists then append the below mentioned code in the same.

function yourthemenamehere_theme(&$existing, $type, $theme, $path) {
   $hooks['user_login_block'] = array(
     'template' => 'templates/user-login-block',
     'render element' => 'form',
   return $hooks;
function yourthemenamehere_preprocess_user_login_block(&$vars) {
  $vars['name'] = render($vars['form']['name']);
  $vars['pass'] = render($vars['form']['pass']);
  $vars['submit'] = render($vars['form']['actions']['submit']);
  $vars['rendered'] = drupal_render_children($vars['form']);

Now save and close!

3) Now in side your theme directory there will be a folder called "template". if its not there please create it there only and then create a php file inside that folder called: "user-login-block.tpl.php" Inside this file, put the following code:

<div id="user-login-block-container">
  <div id="user-login-block-form-fields">
    <?php print $name; // Display username ?>
    <?php print $pass; // Display Password ?>
    <?php print $submit; // Display submit ?>
    <?php print $rendered; // Display hidden elements (required for successful login) ?> 
  <div class="links">
    <a href="/user/register">Singup</a> OR <a href="/user/password">Forgot Password</a>

4) IMPORTANT STEP , navigate to "admin/config/development/performance" and click "clear all caches" -- this is critical because only after deleting cache you can able to see the changes in your login block.

Now you can change the stucture of user-login-block.tpl.php as your wish.

I hope this can help you.

  • PHP Weblineindia: seems you have given the answer in detail , becuase when we click on logini wanted to add a request new password link tab , i really appriciate, before that if i add this code will it make any changes like adding and removing block on user login page ?any how i will be very thankful if it works, million thanks in advance.
    – neethu
    Sep 29, 2015 at 6:15
  • First of all if you think this answer has helped you in any manner then you can always appreciate us by up voting the answer. Now to answer your question regarding effects of this code, it will not make any difference in the login page it will effect only to the block rather login block which can be displayed any region.
    – PHP Team
    Sep 29, 2015 at 6:20
  • PHP Weblineindia :Thanks,i did as you suggested, but the request new password tab is not showing when we click on login link.:(though href="/user/password">Forgot Password</a> </div> is exist in code
    – neethu
    Sep 29, 2015 at 6:27
  • When you click on Forgot Password link where it will bring you to? I have checked it and its taking me to the "Request New Password" tab.
    – PHP Team
    Sep 29, 2015 at 6:52
  • forgot password link is not showing,please check the screen shot above.even i tried to inspect the element and tried to add below code <div class="tabs"> <h2 class="element-invisible">Primary tabs</h2><ul class="tabs primary"><li><a href="/mcms/user/register">Create new account</a> <a href="/mcmss/user/password">Forgot Password</a></li> <li class="active"><a href="/mcms/user" class="active">Log in<span class="element-invisible">(active tab)</span></a></li> </ul> </div> in user-login-block.tpl file but its no use:(
    – neethu
    Sep 29, 2015 at 6:57

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.