Created
November 8, 2015 11:19
-
-
Save sohelamin/c74a8255236e278d6aab to your computer and use it in GitHub Desktop.
Laravel & Wordpress Login Together
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::get('/wordpress', function(){ | |
require('..\wordpress\wp-load.php'); | |
return loginUser(Auth::user()->username); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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