I have a view in Drupal 7 that lists PDF files. I want to keep track of the users that open that file; so I want that, if they are not logged in when they click, they are sent to the login/sign up page. I have already accomplished this using two views with different permissions, but the problem is that, after they sign up, they are redirected to the user profile page, as opposed to the PDF file.

How can I accomplish this?

3 Answers 3


All forms in Drupal support a internal destination parameter.

When you link to the user or user/register form, you can add ?destination=[url]


Since you display the files-list with Views, you will need to re-write the files link to include the destination parameter. If you output the link with l(), you can add the extra url data in l's third parameter like

l('Sign in to View', 'user', 'destination=node/1');
  • Tried this approach, unsuccessfully. Rewrote the link to include the pdf file (example.net/user?destination=http://example.net/sites/default/…). It goes to the user login page, but after it logins, it does not go to the pdf file, it still goes to the user account page...am I missing something?
    – Lucrozade
    Jan 8, 2012 at 20:07
  • Sorry, I have now added info, pointing out that this only works for internal paths, not absolute, so that would be example.net/user?destination=sites/default/files/datasheets/…
    – Letharion
    Jan 8, 2012 at 21:04
  • That worked!The problem I have is this:<br /> 1.The user goes to the view and clicks on the pdf link<br /> 2.The link takes the user to the view with the user login form on top<br /> 3.The user logs in<br /> 4.The pdf opens<br /> 5.If the user clicks "back" on the browser, it takes him to the same view (even though he is logged in now) with the user info on top of the view<br /> 6.If the user clicks on another pdf link, it does not open the link, it goes to the same page, and then it cycles there, because those pdf links have the /user?destination<br /><br />Is there a way to solve this? Thanx
    – Lucrozade
    Jan 9, 2012 at 16:31

The Login Destination module is for all types of logins and registrations. The project pages says, "It is also possible to keep users on the currently visited page after logging in or out."

I haven't used it before, but I hope it solves your problem.


You can do this with rules. Use the after login event and add an action to transfer the user to the page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.