Skip to content

Instantly share code, notes, and snippets.

@sohelamin
Created November 8, 2015 11:19
Show Gist options
  • Save sohelamin/c74a8255236e278d6aab to your computer and use it in GitHub Desktop.
Save sohelamin/c74a8255236e278d6aab to your computer and use it in GitHub Desktop.
Laravel & Wordpress Login Together
<?php
Route::get('/wordpress', function(){
require('..\wordpress\wp-load.php');
return loginUser(Auth::user()->username);
});
<?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));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment