How To Redirect In Same Page or Custom Page After Login In WordPress?

// Redirection in same page after login


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();
}
}

function my_login_redirect( $redirect_to, $request, $user ) {
    $redirect_to = home_url() . '/home/';

    return $redirect_to;

}
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );

// Redirection in same page after login 

Comments

Popular posts from this blog

Remove Add New Post Sub Menu From Custom Post

How To Remove and Add Visit Site Menu From WordPress Admin Bar?

Register Custom Post Type