Last active
July 5, 2021 06:17
-
-
Save cameronjonesweb/5c5305b92cdd9b00f851c093b44622a4 to your computer and use it in GitHub Desktop.
Automatically create admin user
This file contains hidden or 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 | |
/** | |
* Create an admin user | |
*/ | |
function cameronjonesweb_create_admin_user() { | |
$username = 'username'; | |
$password = 'password'; | |
$email = '[email protected]'; | |
if ( ! username_exists( $username ) && ! email_exists( $email ) ) { | |
$user_id = wp_create_user( $username, $password, $email ); | |
$user = new WP_User( $user_id ); | |
$user->set_role( 'administrator' ); | |
} | |
} | |
add_action( 'init', 'cameronjonesweb_create_admin_user' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment