wordpress - Is it possible to customize the logout page or create a custom logout page in Wordpress?
问题描述
At the moment if the user navigates to the default logout
page it looks like this:
This is not consistent with the theme of my website so I would like this content inside my own custom page. Can this be done?
I have a plugin installed My Theme Plugin which is designed to let me specify a logout page but I do not know how to construct it.
解决方案
由于这可能对其他人有所帮助,因此我将添加我的评论作为答案。
您需要最初使用logout_url
过滤器 - https://developer.wordpress.org/reference/hooks/logout_url/
logout
这将允许您在用户单击链接时设置页面。接下来,您只需创建所需的页面(基本 WordPress 页面、特殊模板等)。
在该页面上,您将使用wp_logout_url()
设置Are you sure you want to logout
文本的链接。例如
<a href="<?php echo wp_logout_url( home_url() ); ?>">Logout</a>
这将在用户注销后将用户重定向到主页。
编辑:添加到内容的简码:
function wpso58817718_add_logout_link( $atts ){
return '<a href="' . wp_logout_url( home_url() ) . '">Logout</a>';
}
add_shortcode( 'logout_link', 'wpso58817718_add_logout_link' );
然后你可以做[logout_link]
wp_logout_url( home_url() )
如果您不希望它转到主页,则必须更新结束 URL 。
推荐阅读
- django - 'QuerySet' object has no attribute 'pk' , how I can get the Id of the post from home view?
- javascript - 如何等待直到 nock 被调用
- xaml - WinUI 3 可以用于 xaml 树的屏幕外渲染吗?
- python - TensorFlow 1.15 中的调节参数和移动平均衰减数是什么?
- applepay - 苹果支付 EMV 交易
- reactjs - 如何使用 React Hooks 在另一个组件中获取表单的输入值
- geocoding - 错误的地理编码结果
- swift - 在范围内找不到类型“AWSS3TransferManagerUploadRequest”
- python-2.7 - 如何将列表添加到字典中的相应键?
- sql - 如果 column1 与所需条件不匹配,则选择 column2