I am using the private upload module to protect some files for members only access. If a user clicks on a file that is restricted, then they get taken to an access denied page, which I re-themed to show a login prompt using the code below:

 <div id="content-area">
          <?php print $content; ?>
          <?php if (!$logged_in) : ?>
          <?php echo"To access this additional content, you must be a member.
Please sign up. It’s quick, it’s free, it’s easy!"?>
          <?php print drupal_get_form("user_login") ?>
          <?php echo 'If you are not a member please sign up.'; ?>
          <?php print drupal_get_form('user_register'); ?>

           <?php endif; ?>
           
        </div>

However! Once I login using this form, I can see the file i was after, which is fine but, it also still shows the login page/fields. It doesn't re-direct to the file in the browser, it just downloads it and auto opens it. Is there some re-direct php code I can use to alter my code, in order to re-direct to the file in the browser and actually make it look like the person is logged in?

Becky

Comments

sunwin’s picture

<div class="content clear-block">
          <?php if (!$logged_in): ?>
          <?php echo"To access this additional content, you must be a member.
Please sign up. It's quick, it's free, it's easy!"?>
          <?php print drupal_get_form("user_login") ?>
          <?php echo 'If you are not a member please sign up.'; ?>
          <?php print drupal_get_form('user_register'); ?>
		         <?php else: ?>
		      <?php print $content ?>
           <?php endif; ?>
  </div>

hope this help you.

beckyjohnson’s picture

Thanks for the feedback. I updated my code but it still does not work and it looks more complete with the else tag but it still doesn't work. It does clearly log me in, but it still leaves the form fields visible and doesn't behave like normal logins should.

I just want to add too that I have a login block avalible on every page on the sidebar. In this case though, I wanted a login form on the content area itself so that it was more visible and user friendly. Do I need to disable the other login block to make this work? I was reading a tutorial that was a little different, that said that you had to disable the core login block in order to get the custom one to show, (http://www.nicklewis.org/node/845) .
Becky

beckyjohnson’s picture

OK i tested this again. It doesn't work right even if i disable the usual login block....

It makes no difference.

beckyjohnson’s picture

OK. I looked at my form with firebug and found this:
<form id="user-login" method="post" accept charset="UTF-8" action="/system/files/private/ITJ9.4.6_Interconnect.pdf">
So, it's going to the form, it's just making the browse download it rather than just go it in a browser. I think this creates a confusing expirence for the user, since it will still appear that they are not logged in. Is there anyway to modify this code?

I am happy to try using hook form alter or something but I'm not sure about how. All the examples look like they make blocks, like the link in my earlier post and I don't want a block, I want something on the page.

Becky