Community

Inserting Login Block in tpl file gives me blank screen for logged in users

I have a login modal setup for my site, which works fine until the user is logged in. At that point, it always tries to take them to /users/username and gives me a blank screen.

This, inserted into my header as the modal, seems to be the problem:

<div id="login_modal" class="reveal-modal medium">
        <h2>Login</h2>
        <p>Please login using your credentials received by email when you register</p>
        <?php
        $form
= drupal_get_form('user_login');
       
$form['actions']['#prefix'] = '<p class="right login-block-links">'.l('Create new account' ,'user/register').' | <a href="'.url('user/password').'">'.t('I forgot my password').'</a></p>';
        print
drupal_render($form);
       
?>

        <a class="close-reveal-modal">&#215;</a>
        </div>

Any ideas? Thanks for your help!

Comments

don't include for logged in users

There are bigger questions being begged here, but in the interest of a quick solution... conditionally include the modal form only for non-logged-in users:

<div id="login_modal" class="reveal-modal medium">
        <h2>Login</h2>
        <p>Please login using your credentials received by email when you register</p>
        <?php
       
// if user not logged in, include modal login form
       
if($user->uid <> 0 ) {
            
$form = drupal_get_form('user_login');
            
$form['actions']['#prefix'] = '<p class="right login-block-links">'.l('Create new account' ,'user/register').' | <a href="'.url('user/password').'">'.t('I forgot my password').'</a></p>';
             print
drupal_render($form);
        }
       
?>

        <a class="close-reveal-modal">&#215;</a>
</div>

Thanks

Big help! Thank you!