I am using drupal for one of my portals. Logged in users can see the "documentation link" button in the application which is pointed to an html page. My concern is that, that link is accessible even if someone bookmark the link and open it without logging in to drupal portal. Is there some option/module in drupal available so that if someone access our documentation link directly, it should redirect to login page and load the html page if he is already logged in.

  • 1
    You could set something like that up but it would be awkward and goes against good practice (and not something someone's likely to write a tutorial for here). You'd have to change the HTML page to something dynamic whichever way you look at it, so you may as well do it the proper way and move your HTML page(s) into Drupal's routing, protecting with permissions as normal – Clive Dec 1 '17 at 9:59

Assuming that documentation link is a landing page either resulting from a content type or View Page, you can easily restrict the access to that page via permissions. The concept can be found using Node View Permissions. Although the module is overkill, it will provide ways on how to use it. The recommendations would be to do this through standard permissions first and then use modules or write your own custom module to do this for you.

Additionally you could write a hook that checks to see if user is an anonymous user, if so then let them through otherwise redirect them to a login page. In D7, you can write a hook to check the user_is_logged_in variable. In D8 this answer to check for logged in users.

Other module:

  1. Content Access

Also when you add questions, please indicate if it's for D7 or D8.

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.