duanbei8904 2017-03-07 19:48
浏览 96
已采纳

Laravel集成中的Wordpress

I have one system (built in Laravel 4.2) and I want to integrate it with Wordpress.

Only authenticaed users can access this blog.

I think in 2 options:

1 -> In routes.php include something like

Route::group(array('before' => 'auth')), function() {
    Route::get("wordpress", function() {
         require_once public_path() . '/blog/wp-load.php';
         exit;
    });
});

Only auth users can see blogs routes. If someone try to access without login, It will show 404 error (this code doesn't work, only one example).

2 -> Integrate Laravel with Wordpress. When create a new user in Laravel, It will create also in Wordpress. When access blog, It will automatically log user into Wordpress.

  • 写回答

2条回答 默认 最新

  • dsfsad089111 2017-06-09 19:34
    关注

    Mahmoud, thank you.

    I solved this problem with the function wp_set_auth_cookie($user_id, true);

    After log-in in my system I call one function that use wp_set_auth_cookie and login the user into Wordpress.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部