Hi

I have created a custom page-user.tpl.php file that puts the three forms (Login, Register and lost password) into the same page.

Code is:

		<div id="main">
	        <?php if ($mission) { ?><div id="mission"><?php print $mission ?></div><?php } ?>
	        <?php print $breadcrumb ?>
	        <?php drupal_set_title($title = 'Login or Register'); ?>        
	        <?php if ($title) { ?><h1 class="node-title"><?php print $title ?></h1><?php } ?>
	        <?php if ($show_messages) { print $messages; } ?>
	        <?php print $help ?>
          <table>
          <tr>
          <td>
          <?php $form = drupal_get_form('user_login'); ?>
          <h3>Existing users login</h3>
          <?php print $form; ?>
          <?php $form = drupal_get_form('user_pass'); ?>
          <h3>Forgotten password?</h3>
          <?php print $form; ?>
          </td>
          <td>
          <?php $form = drupal_get_form('user_register'); ?>
          <h3>Create new account</h3>
          <?php print $form; ?>
          </td>
          </tr>
          </table>
	        <?php print $feed_icons; ?>				
						
		</div>

Renders great, but when a user requests a new password, and clicks the link in the email, it takes them to this page again and doesn't log them in so they can edit their password.

Any ideas?

Thanks

Glenn

Comments

abdu’s picture

User get redirected to my account edit to change the password.
In your case you have changed the page-user.tpl to just display these form alone even if the user is logged in

Change your tpl as below

<div id="main">
        <?php if ($mission) { ?><div id="mission"><?php print $mission ?></div><?php } ?>
        <?php print $breadcrumb ?>
        <?php drupal_set_title($title = 'Login or Register'); ?>        
        <?php if ($title) { ?><h1 class="node-title"><?php print $title ?></h1><?php } ?>
        <?php if ($show_messages) { print $messages; } ?>
        <?php print $help ?>
        <?php global $user; if($user->uid) { ?>
        <?php print $content; ?>
       <?php } else { ?>
          <table>
          <tr>
          <td>
          <?php $form = drupal_get_form('user_login'); ?>
         <h3>Existing users login</h3>
          <?php print $form; ?>
          <?php $form = drupal_get_form('user_pass'); ?>
          <h3>Forgotten password?</h3>
          <?php print $form; ?>
          </td>
          <td>
          <?php $form = drupal_get_form('user_register'); ?>
          <h3>Create new account</h3>
          <?php print $form; ?>
          </td>
          </tr>
          </table>
        <?php } ?>
        <?php print $feed_icons; ?>	

</div>
glennnz’s picture

Ah, of course!

It's always easy once someone points out the answer ;-)

Thanks

Glenn

--UPDATE--

That didn't work....

:-(

Glenn

Glenn
THECA Group

adrianmak’s picture

subscribe

adrianmak’s picture

I tried this snippet of code and it work as expected
but how to get rid of the tab ?

http://i36.photobucket.com/albums/e28/adrianmak2/Capture-14.jpg

euricojardim’s picture

Hi all,

Any workaround? Please! I have the exactly same problem...

Thanks.

Best Regards,
Eurico

euricojardim’s picture

OK... I got it...

I check if the arg(1) == 'reset' then print $content. Like $user->uid...

...
<?php 
  global $user; 
  if($user->uid || arg(1) == 'reset') { ?>
        <?php print $content; ?>
 <?php 
  } else { 
  ?>
...
nzcodarnoc’s picture

This is fantastic - love your work!

pipicom’s picture

Sweet! Works like a charm..

filtermusic.net

queryblitz’s picture

I had some trouble until I realized that I needed to copy the parts of my page.tpl.php that I wanted to include into the page-user.tpl.php. The code here just spits out the actual login and register fields/inputs.
I also changed the name to page-user-login.tpl.php so the user account page wouldn't be affected.

Thanks for the code, you can see it at http://lickitornot.com/user/login

bmkaradia’s picture

How can handle validations for separate each form in the same page ?