0

Some sections of my website have to be protected by a password. I made an element in the menu list (blog category) with restricted access to “registered” users.

When I’m logged, by clicking on this menu element, I am correctly redirected to the expected page. Conversly, by clicking on this menu element as an anonymous user, I am redirected to the page “Error 404 - Page not found”.

Do you know how can i redirect anonymous users to the login page?

2
  • Hello Nicola - any link to that page to have a look?
    – FFrewin
    Jun 28, 2016 at 13:26
  • When the menu item has restricted access for "registered" it should not show up in the menu if you use the page as guest user. In the preferences of the login module you can enter the pages someone logging in or out should be redirected to.
    – lars k.
    Jun 29, 2016 at 7:53

2 Answers 2

1

I fixed it! This is how:

  1. Create a menu item with access registered with the description "ata" and menu item type category blog that links to your "ata" category. This will only be visible to logged in users.
  2. Create a menu item with access guest (not public), with the description "ata" and menu item type login form. Set the login redirect to the URL of the item you created in 1. This will only be visible to users who are not logged in.

So I have 2 different menus but I see only one. just a little trick..

0

From the article at Joomla Docs: Auto redirect guests to login

  1. Create a new menu from menu manager, say it is named "hidden menu".
  2. Add any menu items that will be accessible only to registered users (for example, "Submit an Article"). Set the required access levels of these menu items to "Registered".
  3. Do NOT create a module for the "hidden menu". It will not be displayed on any page, so it doesn't need a module.
  4. 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.

  5. Create a module of type "mod_mainmenu" for this menu, just like you do for any menu.

  6. If you want sub-menus, make sure you've added the sub-menu items in the "main menu" and not the "hidden menu".

Now, when a guest (non-logged-in user) accesses the "Submit an Article" menu choice, it redirects them to the login page. 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.

2
  • 1
    it doesn't work. I've done but I still see 404 page. BUT: I fix it! That's how: 1. Create a menu item with access registered with the description "ata" and menu item type category blog that links to your "ata" category. This will only be visible to logged in users. 2. Create a menu item with access guest (not public), with the description "ata" and menu item type login form. Set the login redirect to the URL of the item you created in 1. This will only be visible to users who are not logged in. So I have 2 different menu but I see only one. just a little trick...
    – nicola842
    Jun 29, 2016 at 14:12
  • Nice. Than make your solution as an answer and accept it. I dont care about reputation points, and your answer might be a good solution for someone looking to solve similar problem.
    – Mikan
    Jun 29, 2016 at 14:24

Your Answer

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

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