Skip to content

Instantly share code, notes, and snippets.

@francosalcedo
Created July 17, 2020 05:02
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 francosalcedo/59d6f8880019e9d1dd0b517d1c3d7ab0 to your computer and use it in GitHub Desktop.
Save francosalcedo/59d6f8880019e9d1dd0b517d1c3d7ab0 to your computer and use it in GitHub Desktop.
Login wp admin without password in one file (localhost)
<?php
require __DIR__ . '/wp-load.php';
$username = 'admin';
$user = get_user_by('login', $username );
// 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