dongmei9203 2015-06-03 17:17
浏览 62

如何要求wordpress登录才能查看wordpress网站中的子目录?

I have my Wordpress site at xroads.com

Inside, there is a folder called "_warehouse" which contains a php CRUD app

Is it possible to require the same login page I use for the Wordpress site to view the _warehouse directory?

Thanks in advance!

enter image description here

  • 写回答

2条回答 默认 最新

  • dsqbh42082 2015-06-03 18:04
    关注

    If the user already has an account in WordPress:

    Redirect the user to the login form. Use wp_login_url with the $redirect parameter to set where they go after logging in:

    $loginUrl = wp_login_url( home_url('_warehouse') );
    

    https://codex.wordpress.org/Function_Reference/wp_login_url

    Then use the wp_login action to manually authenticate the user in your application:

    add_action('wp_login', function($username, $user) {
        // Log user into external application
    }, 10, 2);
    

    https://codex.wordpress.org/Plugin_API/Action_Reference/wp_login

    Actually setting the user as "logged in" is going to depend on how your external application is setup. It could be as simple as setting a session variable and then checking if that is set in your warehouse app.

    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?