Skip to content

Instantly share code, notes, and snippets.

@nickdavis
Created November 9, 2013 16:08
Show Gist options
  • Save nickdavis/7386926 to your computer and use it in GitHub Desktop.
Save nickdavis/7386926 to your computer and use it in GitHub Desktop.
Use with extreme caution only. Place the code (after <?php) in your active theme's functions.php file and then load one page on the website. Afterwards delete code from functions.php immediately, login with your new admin username and password and then change your password immediately.
<?php
/*
* Create New Admin Account in WordPress via FTP
* @link: http://stephanis.info/2011/08/11/create-new-admin-account-in-wordpress-via-ftp/
*
*/
function add_admin_acct(){
$login = 'myacct1';
$passw = 'mypass1';
$email = 'myacct1@mydomain.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