我希望用户在体验了站点之后,通过时间推移或/和浏览几个页面,重定向到自定义登录/注册页面。
我发现这段代码强制用户在访问网站之前登录,但我正在寻找更具体的内容。
add_action(\'template_redirect\', \'redirect_to_login\');
function redirect_to_login(){
if(!is_user_logged_in()){
// user not logged in so redirect them to login page
$redirect_url = \'\' // you can determine where to redirect user after they login
wp_redirect( wp_login_url($redirect_url), 301 ); exit;
}
}
非常感谢!