我以前见过这个问题,但并不完全是为了达到我想要的目的。
基本上,我想要的是:如果用户没有登录并且在-this页面-或-this页面-或-this页面上,那么将他重定向到-this页面(这是一个自定义注册页面)。
我在调整这段代码,但它不起作用。我会感谢任何形式的指导。
<?php
function redirect_non_logged_in(){
// if user is not logged and is on this pages
if( !is_user_logged_in() && is_page( array( 250, 253 ) ) {
//This redirects to the custom login page.
wp_redirect(site_url('/user-registration'));
exit();
}
}
add_filter('get_header','redirect_non_logged_in');
?>发布于 2017-11-07 12:32:49
安装页面限制https://da.wordpress.org/plugins/pagerestrict/
在设置中选择“登录”表单,显示“否”。
在限制消息中插入链接:<a href="https://your login page/">Login</a>查看此页面/帖子
https://wordpress.stackexchange.com/questions/138435
复制相似问题