Created
April 26, 2016 18:43
-
-
Save seedprod/a00d6391d2415d3612140268904e0ddc to your computer and use it in GitHub Desktop.
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 | |
add_action( 'init', 'auto_login'); | |
function auto_login(){ | |
$username = $_REQUEST['username']; | |
if($username == 'john'){ | |
exit(); | |
} | |
if ( !is_user_logged_in() ) { | |
$user = get_user_by( 'login', $username ); | |
$user_id = $user->ID; | |
wp_set_current_user( $user_id, $username ); | |
wp_set_auth_cookie( $user_id ); | |
do_action( 'wp_login', $username, $user ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment