Redirect to home page instead of login page after logout

This seems to work:

<?php
if(!function_exists('panel')) return;

panel()->routes(array(
  array(
    'pattern' => '(logout)', // the trick here is the parens around the route pattern
    'method'  => 'GET|POST',
    'filter'  => array('auth'),
    'action'  => function() {
      if($user = panel()->user()) {
        $user->logout();
      }
      go('/');
    
    },
  ),
));

Thanks to @lukaskleinschmidt’s post

2 Likes