英文:
Prevent the back action after logout in wordpress
问题
我试图在WordPress注销后阻止返回按钮。当我从管理面板注销时,将我重定向到登录页面,然后当我点击返回按钮时,页面加载管理面板缓存(如果在缓存页面上点击元素,将重定向到登录页面,因为会话已过期)。
如何在WordPress中防止注销后的返回操作?
WordPress是否有任何防止缓存页面的函数?
我必须使用JavaScript吗?
备注:我的Web服务器是NGINX。
英文:
I am try to prevent back button after logout in WordPress. When I log out from admin panel redirect me to login page then when I click on back button page load admin panel cached (if click on elements in cached page redirect to login page because session expired).
How can I Prevent the back action after logout in WordPress?
WordPress have any function for prevent cache page?
I must use JavaScript?
Notes: My web server is NGINX
答案1
得分: 2
以下是翻译好的部分:
在许多不同的浏览器上似乎都有效的东西在这里。
<br />转到您的 wp-includes/functions.php 文件,并将此代码添加到底部(您可能需要清除您的 WordPress 缓存一次,以便它显示在页面上。
function custom_admin_js_force_logout() {
echo '"
<script>
window.onunload = function(){};
if (window.performance && window.performance.navigation.type === window.performance.navigation.TYPE_BACK_FORWARD) {
document.body.innerHTML=null; // 在重新加载之前隐藏页面
location.reload();
}
</script>
"';
}
add_action('admin_footer', 'custom_admin_js_force_logout');
英文:
Here is something I use and seems to work on many different browsers.
<br />Go to your wp-includes/functions.php file and add this code at the very bottom (you may need to clear your wordpress cache one time so it shows on the pages.
function custom_admin_js_force_logout() {
echo '"
<script>
window.onunload = function(){};
if (window.performance && window.performance.navigation.type === window.performance.navigation.TYPE_BACK_FORWARD) {
document.body.innerHTML=null; // hide page before reload
location.reload();
}
</script>
"';
}
add_action('admin_footer', 'custom_admin_js_force_logout');
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论