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.