Created
August 29, 2019 09:06
-
-
Save waylay/692d71d4621001fd3b6a0b07ae5f7445 to your computer and use it in GitHub Desktop.
WordPress PHP login
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 | |
if($_SERVER['REMOTE_ADDR'] == 'x.x.x.x') { | |
$user_id = 1; | |
$user = get_user_by( 'id', $user_id ); | |
if( $user && !is_user_logged_in()) { | |
wp_set_current_user( $user_id, $user->user_login ); | |
wp_set_auth_cookie( $user_id ); | |
do_action( 'wp_login', $user->user_login, $user ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment