Block overriding with template file doesn't work The Drupal version I'm using is v7.34. I'm using sub-theme created from Bootstrap as base theme.
My problem is, I want to override the "User Login Block" and put it in the header region (top bar), so I create these file in templates folder in my sub-theme:


page.tpl.php

//this simply do
print render($page['header']);
region--header.tpl.php

$search_block = module_invoke('search', 'block_view', 'search');
$login_block = module_invoke('user', 'block_view', 'login');
print render($search_block); 
print render($login_block);
search-block-form.tpl.php

//this copied from base theme and only modified some html tag
block--user--login.tpl.php

//this simply print out some simple text
print ("blahhhhhhhhhhhhhh");


The result is, only search block is rendered as override, and the login block is rendered as default block, not rendered as the one I override.
I did some search but nothing matches my fault.
To Alter User login block


Find the template.php file for the theme you're working on. Should be in the root of the theme folder for your theme
Assuming the "yourthemename_hook" function does NOT exist, at the bottom of your template.php file insert the following code:



function yourthemenamehere_theme(&amp;$existing, $type, $theme, $path) {
   $hooks['user_login_block'] = array(
     'template' =&gt; 'templates/user-login-block',
     'render element' =&gt; 'form',
   );
   return $hooks;
 }
function yourthemenamehere_preprocess_user_login_block(&amp;$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 create a directory inside your theme's directory called "templates" (assuming it doesn't exist already)
Then create a php file inside that folder called: "user-login-block.tpl.php"
Inside this file, put the following code:



&lt;div id="user-login-block-container"&gt;
  &lt;div id="user-login-block-form-fields"&gt;
    &lt;?php print $name; // Display username field ?&gt;
    &lt;?php print $pass; // Display Password field ?&gt;
    &lt;?php print $submit; // Display submit button ?&gt;
    &lt;?php print $rendered; // Display hidden elements (required for successful login) ?&gt; 
  &lt;/div&gt;
  &lt;div class="links"&gt;
    &lt;a href="/user/register"&gt;Create an Account&lt;/a&gt; | &lt;a href="/user/password"&gt;Forgot Password&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;




CRITICAL STEP as an admin on your website, navigate to "admin/config/development/performance" and click "clear all caches" -- if you don't, then these changes won't display on your website
Modify the html markup inside "user-login-block.tpl.php" to your heart's content, and don't forget that you can also add those css classes to your main style.css file (AFAIK)