admin管理员组文章数量:1134599
logout_url = wp_logout_url( $custom_login_url);
echo "<a class='handler-login-link logout' href='{$logout_url}'>".__("Logout","pixel_framework")."</a>";
I have created a custom logout link that is supposed to redirect users to a custom login page (within the same domain).
Logout is working fine, but the redirection is not working at all. After logging out redirected to the default wp-login page.
I tried to inspect HTML behind the link it is like this:
/?logout=0b2adca060&redirect_to=/
logout_url = wp_logout_url( $custom_login_url);
echo "<a class='handler-login-link logout' href='{$logout_url}'>".__("Logout","pixel_framework")."</a>";
I have created a custom logout link that is supposed to redirect users to a custom login page (within the same domain).
Logout is working fine, but the redirection is not working at all. After logging out redirected to the default wp-login page.
I tried to inspect HTML behind the link it is like this:
https://example.com/?logout=0b2adca060&redirect_to=https://example.com/haendler-login/
Share
Improve this question
asked Apr 6, 2021 at 15:59
MMKMMK
5384 silver badges11 bronze badges
1
|
1 Answer
Reset to default 1Use this logout link <li class="signOut"><a href="<?php echo wp_logout_url(); ?>" title="Logout">Logout</a></li>
And add below code in your functions.php file to redirect the user to the page you want:
add_action( 'wp_logout', 'auto_redirect_user_after_logout');
function auto_redirect_user_after_logout(){
wp_redirect( 'https://example.com/haendler-login/' );
exit();
}
本文标签: wplogouturl redirect not working
版权声明:本文标题:wp_logout_url redirect not working 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736862450a1955976.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
https://example.com/wp-login.php?action=logout&_wpnonce=12345&redirect_to=
etc. (and the redirect-to URL urlencoded). i.e. it should use the login page to log out. Unless you have a different logout handler, and a logout_url filter from one of your plugins? I'd guess that logout handler doesn't support the redirect. – Rup Commented Apr 6, 2021 at 22:22