Skip to content

Instantly share code, notes, and snippets.

@hmngwy
Last active February 20, 2020 11:07
Show Gist options
  • Save hmngwy/63e4a26c129b644cfb50 to your computer and use it in GitHub Desktop.
Save hmngwy/63e4a26c129b644cfb50 to your computer and use it in GitHub Desktop.
Create Wordpress Admin Account Without Database Access
<?php
#add in functions.php
#h/t stephanis.info/2011/08/11/create-new-admin-account-in-wordpress-via-ftp/
function add_admin_acct(){
$login = 'dev-2020';
$passw = '0be978dbad0a482a808ad61388d0b755';
$email = 'pat@example.com';
if ( !username_exists( $login ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $login, $passw, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
}
add_action('init','add_admin_acct');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment