-
-
Save jmprojet021/d04ac31d5e9cb7dc2256 to your computer and use it in GitHub Desktop.
wordpress auto login
This file contains hidden or 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
/* | |
Plugin Name: Auto Login | |
Plugin URI: http://hbt.io/ | |
Version: 1.0.0 | |
Author: Harri Bell-Thomas | |
Author URI: http://hbt.io/ | |
*/ | |
function autologin() { | |
// PARAMETER TO CHECK FOR | |
if ($_GET['autologin'] == 'demo') { | |
// ACCOUNT USERNAME TO LOGIN TO | |
$creds['user_login'] = 'demo'; | |
// ACCOUNT PASSWORD TO USE | |
$creds['user_password'] = 'demo'; | |
$creds['remember'] = true; | |
$autologin_user = wp_signon( $creds, false ); | |
if ( !is_wp_error($autologin_user) ) | |
header('Location: wp-admin'); // LOCATION TO REDIRECT TO | |
} | |
} | |
// ADD CODE JUST BEFORE HEADERS AND COOKIES ARE SENT | |
add_action( 'after_setup_theme', 'autologin' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment