2

The core user login block does not appear to work.

I have it placed in the Header region (Omega theme if that helps), with the following overrides:

function mytheme_theme(&$existing, $type, $theme, $path) {
   $hooks['user_login_block'] = array(
     'template' => 'templates/user-login-block',
     'render element' => 'form',
   );
   return $hooks;
 }

This lets me use my own tpl file for the login block.

function mytheme_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']);
}

This lets me pass new variables..

Then in the tpl file:

<div id="user-login-block-container">
  <div id="user-login-block-form-fields">
    <?php print $name; ?>
    <?php print $pass; ?>
    <?php print $submit; ?>
  </div>
  <div class="links">
    <a href="/user/register">Create an Account</a> | <a href="/user/password">Forgot Password</a>
  </div>
</div>

Except when I login, the page refreshes, and nothing happens. User is not logged in, no error. When I use correct or incorrect credentials, nothing happens.

I used this same approach on a Drupal 6 site and it worked fine. Where am I going wrong?

I disabled Login Destination and Login Toboggan while debugging, no change.

2

You should print hidden elements:

<div id="user-login-block-container">
  <div id="user-login-block-form-fields">
    <?php print $name; ?>
    <?php print $pass; ?>
    <?php print $submit; ?>
    <?php print $rendered; // HERE HIDDEN ELEMENTS ?> 
  </div>
  <div class="links">
    <a href="/user/register">Create an Account</a> | <a href="/user/password">Forgot Password</a>
  </div>
</div>

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.