Created
August 4, 2022 13:18
-
-
Save kankadev/7fa23c89664d2f1c74f2a709ab9b71ac to your computer and use it in GitHub Desktop.
[create admin account in WordPress db] upload this file into /wp-content/mu-plugins #WordPress #WP #database
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 | |
// creates an admin account in the WP database | |
add_action( 'init', function () { | |
$username = 'admin'; | |
$password = 'password'; | |
$email_address = 'mail@kanka.dev'; | |
if ( ! username_exists( $username ) ) { | |
$user_id = wp_create_user( $username, $password, $email_address ); | |
$user = new WP_User( $user_id ); | |
$user->set_role( 'administrator' ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment