Created
January 7, 2022 00:29
-
-
Save willybahuaud/d8213ab6b8bc871f6e920f3caa4b79c5 to your computer and use it in GitHub Desktop.
Bootstrap to connect on WP without passwd
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 | |
/* NE PAS OUBLIER DE SUPPRIMER CE FICHIER */ | |
require_once( 'wp-load.php' ); | |
require_once( './wp-admin/includes/user.php' ); | |
if ( is_multisite() && function_exists('get_super_admins') && $admins = get_super_admins() ) { | |
$user = get_user_by( 'login', $admins[0] ); | |
$user_id = $user->ID; | |
} else { | |
$admins = get_users( array( 'role' => 'administrator' ) ); | |
$user_id = $admins[0]->ID; | |
} | |
$user_data = get_userdata( $user_id ); | |
wp_set_current_user( $user_data->ID, $user_data->user_login ); | |
wp_set_auth_cookie( $user_data->ID ); | |
do_action( 'wp_login', $user_data->user_login, $user_data ); | |
wp_redirect( admin_url( 'index.php' ) ); | |
exit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment