wp_redirect进入无限循环

我需要检查登录的用户并使用wp_redirect重定向到页面, 但是它经过多次重定向

我试过了template_redirect和init钩子

add_action( 'template_redirect', 'redirect_to_specific_page' );

function redirect_to_specific_page() {

if ( !is_user_logged_in() ) {
    wp_redirect( 'http://localhost/lawyer_portal/login/' );
    exit;
   }
}

#1


尝试以下代码片段-

add_action( 'template_redirect', 'redirect_to_specific_page' );

function redirect_to_specific_page() {
    // Assume that url login slug is a page
    if ( !is_user_logged_in() && !is_page( 'login' ) ) { 
        wp_redirect( 'http://localhost/lawyer_portal/login/' );
        exit;
    }
}

来源:

https://www.srcmini02.com/64667.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_41277.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?