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
1 2 3 4 5 6 7 |
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.
圖片轉代碼服務由CSDN問答提供
感謝您的意見,我們儘快改進~
功能建議
我有一個系統(內置Laravel 4.2),我想將它與Wordpress集成。</ p> \\ n
只有經過身份驗證的用戶才能訪問此博客。</ p>
我認為有2個選項:</ p>
1 - &gt; 在routes.php中包含類似</ p>
Route :: group(array(\'before\'=&gt;\'auth\')),function(){
Route :: get (「wordpress」,function(){
require_once public_path()。\'/ blog / wp-load.php\';
exit;
});
});
</ code> </ pre >
只有身份驗證用戶才能看到博客路線。 如果有人試圖在沒有登錄的情況下訪問,它將顯示404錯誤(此代碼不起作用,只有一個示例)。</ p>
2 - &gt; 將Laravel與Wordpress集成。 在Laravel中創建新用戶時,它也將在Wordpress中創建。 當訪問博客時,它會自動將用戶登錄到Wordpress。</ p>
</ div>
網友觀點:
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.
###
To create a union user system, I suggest that you use WordPress REST API & OAuth (Authentication System)
it has a WordPress plugin you can use the data for both sides, Laravel & WordPress.
To authenticate users from Laravel application to allow them to view WordPress specific directory, you should generate WordPress authentication cookies from Laravel then redirect.
I think these articles may help you to start:
How to use WordPress as a backend for a Laravel Application
1. 帶 [親測] 說明源碼已經被站長親測過!
2. 下載後的源碼請在24小時內刪除,僅供學慣用途!
3. 分享目的僅供大家學習和交流,請不要用於商業用途!
4. 本站資源售價只是贊助,收取費用僅維持本站的日常運營所需!
5. 本站所有資源來源於站長上傳和網路,如有侵權請郵件聯繫站長!
6. 沒帶 [親測] 代表站長時間緊促,站長會保持每天更新 [親測] 源碼 !
7. 盜版ripro用戶購買ripro美化無擔保,若設置不成功/不生效我們不支持退款!
8. 本站提供的源碼、模板、插件等等其他資源,都不包含技術服務請大家諒解!
9. 如果你也有好源碼或者教程,可以到審核區發布,分享有金幣獎勵和額外收入!
10.如果您購買了某個產品,而我們還沒來得及更新,請聯繫站長或留言催更,謝謝理解 !
GG資源網 » Laravel集成中的WordPress