on my site there are a few pages that contain info only for the registered users (of which there are very few). Hence I do not want to display a login-box everywhere on the website (globally) and I do not want to allow registrations via the website.
Instead, I would like to display the login/password fields only if a protected article is viewed (and the viewer is currently browsing as a guest). Once the user logs in, the actual contents of this article should become visible (instead of the login/password field).
Long story short, from the user’s point of view the following should happen:
As a guest:
Click menu item-> Get to a page with a login box-> Once logged in, be forwarded to article for registered users.
As a registered user:
Click menu item-> Article is displayed immediately.
(analagously, if a user opens the URL of a restricted article directly)
My questions is: how do I do that?
- Create a new menu from menu manager, say it is named “hidden menu”.
- Add any menu items that will be accessible only to registered users.
- Set the required access levels of these menu items (“Special” in this example, but it could also be “Registered”). Do NOT create a module for the “hidden menu”. It will not be displayed on any page, so it doesn’t need a module.
- Create your “real” menu (for example, “main menu”) and the menu item that will display for all users (for example “Submit an Article”). The menu item will have a menu item type of “Alias”. It’s “Menu Item” parameter will be the “Submit an Article” menu item on the “hidden menu”. The Access Level for this menu item will be “Public”, since we want everyone to be able to see and use it.
- Create a module of type “mod_mainmenu” for this menu, just like you do for any menu.
- Create a login module and set the access level to “Public”. Make sure the module is displayed only on the “Public” menu item and not the registred item, and select a visible position.
Now, when a guest (non-logged-in user) accesses the “Submit an Article” menu choice, it redirects them to blank page with the “Only for registred visitors” message. . If they log in successfully, they are taken to the desired page (in this case, “Submit an Article”). If there were already logged in, they go there directly.