Skip to content

Instantly share code, notes, and snippets.

Last active Nov 24, 2017
What would you like to do?
WordPress Redirect to Previous Page on Login
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 );
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'];

This comment has been minimized.

Copy link

@alexlii1971 alexlii1971 commented Nov 24, 2017

does it support redirect user to previous page? In multsites? How use these code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment