I have written a plugin for my own site where I have an issue like "after user login to the site if he logout then again if he clicks on browser back button then the previous page showing again instead of login page". Iam trying the below code but it doesn't work.
<script>
window.onhashchange = function() {
<?php if( ! is_user_logged_in()) { $this->tewa_login(); } ?>
}
<script>
My logout code is below:
if ( is_user_logged_in() ) {
$data .= '<li><a class="add-new" href="'. wp_logout_url() .'" class="btn btn-primary" >'.$this->icon_sign_out.' Logout</a></li>';
}
Can the below code works or not?
function my_redirect(){
<script>
location.reload();
</script>
exit();
}
add_filter('wp_logout','my_redirect');
I think this issue totally browser issue not belongs to server. I think just a page refresh that does the trick. I was using 'wp_logout_url' for user logout. how to do it can anyone plz tell me? Thanks in advance.
I have written a plugin for my own site where I have an issue like "after user login to the site if he logout then again if he clicks on browser back button then the previous page showing again instead of login page". Iam trying the below code but it doesn't work.
<script>
window.onhashchange = function() {
<?php if( ! is_user_logged_in()) { $this->tewa_login(); } ?>
}
<script>
My logout code is below:
if ( is_user_logged_in() ) {
$data .= '<li><a class="add-new" href="'. wp_logout_url() .'" class="btn btn-primary" >'.$this->icon_sign_out.' Logout</a></li>';
}
Can the below code works or not?
function my_redirect(){
<script>
location.reload();
</script>
exit();
}
add_filter('wp_logout','my_redirect');
I think this issue totally browser issue not belongs to server. I think just a page refresh that does the trick. I was using 'wp_logout_url' for user logout. how to do it can anyone plz tell me? Thanks in advance.
Try using wp_redirect after logout. There's an example of how to use it here.
add_action( 'wp_logout', 'auto_redirect_external_after_logout');
function auto_redirect_external_after_logout(){
wp_redirect( 'http://redirect-url' );
exit();
}
if you want to refresh (and not redirect to a different page) use 'get_permalink()'
it's in the docs...
<a href="<?php echo wp_logout_url( get_permalink() ); ?>">Logout</a>