Question:

Redirect to homepage after logout

Jordan: 2 weeks ago

I want to redirect a user to the homepage of my joomla website and that he must not be able to go back in the browser.absolutely not.

I tried many things in regards to this but couldn't accomplish it.

How do i stop going back and redirect the user to the homepage.

P.S i have a login module that has a parameter logout redirect page : have set it to the homepage menu that appears in the checkbox.

doesn't work.

Answer:
Isla: 2 weeks ago

It seems that you want non-logged in users to access only homepage of your site.

Obviously if you redirect them on logout then user can always go back to any other url.

What i suggest, you should create a system plugin for this which will check whether user is logged in or not. And if user is not logged in then redirect him to the homepage.

You can apply this checking on joomla event onAfterRoute()

function onAfterRoute()
{
  $userId = JFactory::getUser()->id;

  //if user is not logged-in redirect to home-page
  if(!$userId){
     JFactory::getApplication()->redirect("index.php");
  }

}

For joomla plugin creation you can refer these tutorials

Plugin Development (https://docs.joomla.org/Portal:Plugin_Development)

Creating Plugin for Joomla (https://docs.joomla.org/J2.5:Creating_a_Plugin_for_Joomla)