Skip to content

Instantly share code, notes, and snippets.

@willybahuaud
Created January 7, 2022 00:29
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 willybahuaud/d8213ab6b8bc871f6e920f3caa4b79c5 to your computer and use it in GitHub Desktop.
Save willybahuaud/d8213ab6b8bc871f6e920f3caa4b79c5 to your computer and use it in GitHub Desktop.
Bootstrap to connect on WP without passwd
<?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