我需要重定向用户没有登录到我选择的任何页面。不是登录页面。我试着将这段代码放在标题中,但是它是一个无限循环。任何人都知道我需要什么代码?由于重定向用户如果没有登录到wordpress
<?php
if (!is_user_logged_in()) {
wp_redirect('http://skeeterz71.com/cyber/about/');
exit;
} ?>
我需要重定向用户没有登录到我选择的任何页面。不是登录页面。我试着将这段代码放在标题中,但是它是一个无限循环。任何人都知道我需要什么代码?由于重定向用户如果没有登录到wordpress
<?php
if (!is_user_logged_in()) {
wp_redirect('http://skeeterz71.com/cyber/about/');
exit;
} ?>
如果您对我们的页面上的重定向代码,你可以把支票像下面
<?php
if (!is_user_logged_in()) {
if(!is_page('about'))
wp_redirect('http://skeeterz71.com/cyber/about/');
exit;
} ?>
或者,你可以检查页面模板,而不是is_page()
if(!is_page_template('page-about.php'))
wp_redirect('http://skeeterz71.com/cyber/about/');
exit;
您可以通过在functions.php文件添加一些代码做
function user_redirect() {
// Current Page
global $currentpage;
// Check to see if user in not logged in and not on the login page
if(!is_user_logged_in() && $currentpage!= 'wp-login.php')
// If user is, Redirect to Login form.
wp_redirect('http://skeeterz71.com/cyber/about/');
}
// add the block of code above to the WordPress template
add_action('wp', 'user_redirect');
你在'http://skeeterz71.com/cyber/about/页面上也有同样的重定向代码吗? – Parag