Skip to content

Instantly share code, notes, and snippets.

@waylay
Created August 29, 2019 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waylay/692d71d4621001fd3b6a0b07ae5f7445 to your computer and use it in GitHub Desktop.
Save waylay/692d71d4621001fd3b6a0b07ae5f7445 to your computer and use it in GitHub Desktop.
WordPress PHP login
<?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