auth_redirect() doesn't send users to the page where they orginally tried to acces
In the site I am building, I'm using theme my plugin so I could make my own login, logout, registration pages.
For the login form, I used the default wp_login_form
input names, and the default value for the hidden type input named redirect_to
which is: ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']
.
for some pages, I want user to login to access to them, so I use the auth_redirect()
function, as expected it sends users to the login page, but after login, doesn't send them back to the page they were originally.
So I tried to filter the login_redirect
... but it doesn't work. Thanks for your help!
function my_login_redirect_function(){
if(( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] == get_bloginfo('url').'/login'){
return get_bloginfo('url').'/dashboard';
}else{
$urlStartPos= strstr($_SERVER['REQUEST_URI'], 'http');
return(urldecode($urlStartPos));
}
add_filter('login_redirect','my_login_redirect_function');
Topic template-redirect filters redirect Wordpress
Category Web