Last active
November 24, 2017 18:03
-
-
Save tlongren/ffea6b1f1339844e5ddd2cd87044a8ea to your computer and use it in GitHub Desktop.
WordPress Redirect to Previous Page on Login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_login_redirect( $redirect_to, $request, $user ) { | |
$redirect_to = home_url() . '/members/'; | |
return $redirect_to; | |
} | |
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
function my_login_redirect() { | |
$location = $_SERVER['HTTP_REFERER']; | |
wp_safe_redirect($location); | |
exit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
does it support redirect user to previous page? In multsites? How use these code?