【问题标题】:How to password protect wordpress site?如何用密码保护wordpress网站?
【发布时间】:2010-11-29 15:01:54
【问题描述】:

我需要用密码保护我的 wordpress 网站,但主页除外。我需要让每个访问者都能看到主页,但如果他们点击任何可能是网站内的帖子/页面的链接,那么用户应该被重定向到登录页面。任何帮助将不胜感激

【问题讨论】:

    标签: wordpress


    【解决方案1】:
    <?php
    if (is_user_logged_in()){
        echo "Welcome, registered user, here are my lovely posts";
    }
    else {
        header( 'Location: http://www.yoursite.com/login.php' ) ;
    };
    ?>
    

    【讨论】:

      【解决方案2】:
      【解决方案3】:

      对 benhowdle89 的代码稍作修改..

      <?php
      if (is_user_logged_in() || is_home()){
          echo "Welcome, registered user, here are my lovely posts";
      }
      else {
          header( 'Location: http://www.yoursite.com/wp-login.php' ) ;
      };
      ?>
      

      【讨论】:

        猜你喜欢
        • 2023-04-02
        • 2014-05-24
        • 2012-12-13
        • 1970-01-01
        • 1970-01-01
        • 2020-01-24
        • 2013-03-02
        相关资源
        最近更新 更多