[英]Change /wp-login.php?action=logout URL for WordPress to /logout
I've been googling for 20 mins plus and still couldn't find the answer.我已经用谷歌搜索了 20 多分钟,但仍然找不到答案。 I saw this but it's about redirecting to a different page to log out but URL remains the same.我看到了这个,但它是关于重定向到另一个页面以注销,但 URL 保持不变。
I'm looking to change mysite.com/wp-login.php?action=logout
to mysite.com/logout
我正在寻找将mysite.com/wp-login.php?action=logout
更改为mysite.com/logout
Is that possible?那可能吗?
Maybe something like this would work也许这样的事情会奏效
add_filter('parse_request', 'custom_logout');
function custom_logout($request){
if ( $request->query_vars['pagename']=='logout'){
wp_logout();
wp_set_current_user(0);
}
}
Probably you should create a page with slug 'logout' to avoid 404 page可能你应该创建一个带有 slug 'logout' 的页面以避免 404 页面
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.