Think since wordpress the most of a little biatch, login with wordpress as the main one but when that hook triggers you just update the login details in laravels db and set your session _token the Auth::user().
Like a trigger laravel login plugin.
We are using wordpress as our store (using woocommerce). our backend use laravel where users who bought our services can use and manage the services they bought from us. we will eventually move to custom implementation of our store in laravel but right now we don't want to break anything. what i want is to integrate wordpress and laravels login so they don't have to login or register twice. something like github use (if you login at github you are automatically logged in at gist). both laravel and wordpress will use different database (or user tables at least). i can create a user in laravel when someone register at wordpress. but i have no clue how to share login session. why both ? we are using different readily available plugins of woocommerce (multiple subscriptions, addons, product variants etc) which will take a lot of time to port to laravel. any help would be great
@RemiC you can do this
Route::get('/wordpress', function(){
require('..\wordpress\wp-load.php');
return loginUser(Auth::user()->username);
});
in wordpress create a plugin or add loginFunction() to functions.php
function loginFunction($username){
$user_id = username_exists($username);
$userdata = get_userdata($user_id);
$user = set_current_user($user_id,$username);
wp_set_auth_cookie($user_id);
do_action('wp_login',$userdata->ID);
// you can redirect the authenticated user to the "logged-in-page", define('MY_PROFILE_PAGE',1); f.e. first
header("Location:".get_page_link(MY_PROFILE_PAGE));
}
Edit: now Laravel is maintaining the user DB, on creation of user a wordpress method is called which creates the same user and also login that user, same goes for login
Please or to participate in this conversation.