logout redirect to last visited page. | Peter's Login Redirect | Forum
Back to the login redirect plugin page
11:55 am
To use a function instead of a plugin, I found this code attributed to Peter.
wp_redirect(get_option('home'));
die();
}
add_action('wp_logout', 'redirect_logout_home_page');
This works fine to redirect to the home page.
Can you share how to edit this to redirect to the last page the visitor was on when they chose to log-out.
Thank You!
I usually recommend seeing this comment for ideas, as there are a few ways to handle that on login and logout:
1:41 pm
Hmmm. It seems that it is not as simple to have a global redirect to the previous visited page as it is to an absolute url.
I played around with using "$_SERVER['HTTP_REFERER']" as the value, but, no joy.
The WP-Codex gives the example of
for this purpose, but no examples of how to use this within functions.php rather than on a page template.
Can this or something else be adapted to apply this global logout redirect?
Thanks Peter, I apologize for what must be basic 'crap' for you!
10:14 am
Stefano,
iI exactly needed that.
In simplemodal-login.php line 370 place:
and to line 455 place:
$redirect_to = $_POST['referer'];
In admin interface in the URL redirection type "referer".
Peter, wouldnt it be a nice improvement of your cool plugin?
Cheers,
Filip