Wordpress force user to login before view any site content

后端 未结 3 1497
不知归路
不知归路 2020-12-15 11:35

In wordpress I am trying to force user login first before see anything. Means I want my user to first login to view any single page, post or archive and only they can se FAQ

相关标签:
3条回答
  • 2020-12-15 12:08

    There's a plugin you can use for this. Private Only

    0 讨论(0)
  • 2020-12-15 12:19

    Easy way

    // Require login for site
    get_currentuserinfo();
    global $user_ID;
    if ($user_ID == '') { 
      header('Location: /wp-login.php'); exit(); 
    } 
    
    0 讨论(0)
  • 2020-12-15 12:24

    I think you are missing a parenthesis:

    if ( ( is_single() || is_front_page() || is_page() ) 
           && !is_page('login') && !is_user_logged_in()){ 
        auth_redirect(); 
    } 
    
    0 讨论(0)
提交回复
热议问题