Redirecting user after logging in

If I send a link to someone and they have to log in, once they have entered in their details and click ‘submit’ they are taken to the home page of the site. Is it possible once they have entered their details to continue to the page they were linked to originally rather than redirecting to the home page?

What you can do is write a form to login, post to $PHP_SELF, check if the user is logged in and redirect.

Like this:

<? 
$user = site()->user();
if(!empty($user)) { 
	echo "you are logged in and being redirected.";
	sleep(3);
	go('home'); // or wherever...
} 
// do form stuff
?>

You should look into $_SERVER['REQUEST_URI'] and e.g. store that in a hidden input field, so that after the successful login you can retrieve the original wanted target and redirect the user there

I am looking at the same issue right now. Have you been able to create a working example of a redirect to requested page after login?

@criuz

There some working examples in this thread

http://forum.getkirby.com/t/authentication-private-pages-direct-urls/1401/4

1 Like