Created
July 4, 2019 15:42
-
-
Save Matteo182/8b54965d30fc064ea9b59d3e2ef00fbc to your computer and use it in GitHub Desktop.
Funzione per l'autologin
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
/****************************************** */ | |
// Funzione per l'autologin | |
/****************************************** */ | |
function autologin($user_name){ | |
$user = get_user_by('login', $user_name ); | |
// Redirect URL // | |
if ( !is_wp_error( $user ) ) | |
{ | |
wp_clear_auth_cookie(); | |
wp_set_current_user ( $user->ID ); | |
wp_set_auth_cookie ( $user->ID ); | |
$redirect_to = user_admin_url(); | |
wp_safe_redirect( $redirect_to ); | |
exit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment