Created
November 13, 2018 16:41
-
-
Save yanknudtskov/ccf32dca55d2ac77cb150d01d5f1ca39 to your computer and use it in GitHub Desktop.
Create a WordPress Admin user through functions.php - Remember to remove the codesnippet after the user has been created.
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 | |
add_action( 'init', function () { | |
$username = 'USER NAME HERE'; | |
$password = 'PASSWORD HERE'; | |
$email_address = 'EMAIL HERE'; | |
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