wordpress如何禁止直接进入登陆界面

╭飛雪飄零╮ 2016/06/0422:20:2988,3462 474字

如果网站仅供自己登陆,可以使用下面这个方法,只有带参数或者以登陆用户才可以访问wp-admin/ 页面和 wp-login.php 页面。方法步骤如下:

在主题的函数文件functions.php里面加入以下代码

// 后台登陆地址
add_action('login_enqueue_scripts','login_protection');
    function login_protection(){
        if($_GET['user'] != 'sdtclass')  header('Location: /');
    }

 访问地址

访问地址:www.***.com/wp-login.php?user=sdtclass

上面代码中的“user”和“sdtclass”都可以修改成想要的任意参数。

密码找回

密码找回地址:www.***.com/wp-login.php?user=sdtclass&action=lostpassword

同样,上面代码中的“user”和“sdtclass”都可以修改成想要的任意参数。

以上方法希望可以帮到大家。

站长最后更新:2020-2-4
╭飛雪飄零╮
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

评论:8   其中:访客  4   博主  4
    • 雷小天博客 雷小天博客 1
      Google Chrome 55.0.2883.87 Google Chrome 55.0.2883.87 Windows 7 x64 Edition Windows 7 x64 Edition

      雷小天博客 http://www.100txy.com 有换友链的吗

      • 雷小天博客 雷小天博客 1
        Google Chrome 55.0.2883.87 Google Chrome 55.0.2883.87 Windows 7 x64 Edition Windows 7 x64 Edition

        不错 ,有换友链的吗 雷小天博客 http://www.100txy.com

        • 卢松松商城 卢松松商城 1
          Google Chrome 45.0.2454.101 Google Chrome 45.0.2454.101 Windows 7 x64 Edition Windows 7 x64 Edition

          安全保障了

          • 穿石网库 穿石网库 1
            Google Chrome 49.0.2623.112 Google Chrome 49.0.2623.112 Windows Server 2003 Windows Server 2003

            感觉并没有什么具体的用处啊 :mrgreen: :mrgreen: :mrgreen:

              • ╭飛雪飄零╮ ╭飛雪飄零╮
                Google Chrome 45.0.2454.101 Google Chrome 45.0.2454.101 Windows 10 x64 Edition Windows 10 x64 Edition

                @ 穿石网库 防止别人后台登陆咯,呵呵。

                @ 穿石网库