Last active
August 29, 2015 14:10
-
-
Save ooooak/8737362671f529c851bb to your computer and use it in GitHub Desktop.
[wordpress] login user by user id
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 | |
/** | |
* @param Mix $id will user id | |
* @param String $user_login | |
*/ | |
function login_user($id, $user_login) { | |
wp_set_current_user( $id, $user_login); | |
wp_set_auth_cookie( $id ); | |
do_action( 'wp_login', $user_login ); | |
} | |
$user = get_user_by('id', 1); | |
login_user($user->get('id'), $user->get('user_login')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment