Thank you for reading! There's a lot redirecting going on on the site I'm creating. For example, - if not logged in user access a "private" page, he will be redirected to a custom login page. - if the user logs in, he will be redirected to the last page he visited before accessing the login form. Let's call the pages "Profile" and "LogIn". So, if everything goes well should be: > -> not logged try to access **Profile** -> redirect to **LogIn** -> if OK redirect to **Profile** However, when **LogIn** calls wp_get_referer(), it does NOT return **Profile**. Instead it goes "2 pages" back. Is like "wp_get_referer()" is not seing **Profile** as the referer because is acting as a redirection. Just like the "Back" button in the browser would. **If you go to the LogIn through any other page (clicking the link) the redirect after login in works fine.** **page-profile.php** if( !is_user_logged_in() ) { wp_redirect( get_permalink(37) ); //id 37 = page-login.php exit; } **page-login.php** //Set referer $referer = wp_get_referer(); if( !$referer || referer_is_login_page($referer) ) $referer = get_bloginfo('url'); simpleSessionSet('login_referer', $referer); ... //Log the user in ... if ( is_wp_error($user_id) ) $errores = TRUE; else wp_redirect( simpleSessionGet('login_referer', '') );