Blog, Frontpage, Wordpress

How to Redirect WordPress Back to Referring Page After Login?

Do you want to redirect users back to the page they were viewing after logging in? While there’s probably a plugin for this, but I came thru a link where I found this instruction. It works all fine for me. Anyone who wants to redirect users to the same page they were viewing use this instruction.


All you have to do is add this code to your theme’s functions.php.

if( (isset($_GET['action']) && $_GET['action'] != 'logout') || (isset($_POST['login_location']) && !empty($_POST['login_location'])) ) {add_filter('login_redirect', 'my_login_redirect', 10, 3);functionmy_login_redirect() {$location= $_SERVER['HTTP_REFERER'];wp_safe_redirect($location);exit();}}

That’s it!

Comment for more details.


For my other blogs Click Here

old dream creation



Vinoth Kumar

Learner, I love to learn. As they say ' curiosity is the mother of invention ', my curiosity drives me. This made me learn from writing to handling camera and more.