Skip to content

Instantly share code, notes, and snippets.

@sitebuilderone
Created November 24, 2018 03:15
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 sitebuilderone/b70a5e7fc039d9eda6bdff425d9a2847 to your computer and use it in GitHub Desktop.
Save sitebuilderone/b70a5e7fc039d9eda6bdff425d9a2847 to your computer and use it in GitHub Desktop.
Add admin user to WordPress with functions file
add_action( 'init', function () {
$username = 'admin';
$password = 'password';
$email_address = 'webmaster@mydomain.com';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $username, $password, $email_address );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
} );
@sitebuilderone
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment