phpwordpresslaravelintegrate

Wordpress inside Laravel Integration


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.


Solution

  • 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.