Add new Admin User for wordpress using FTP

Add this code to the end of your functions.php file.  It will add a new admin user to your wordpress site in the event you’ve been locked out of your site.


  1. Access the files to your website using FTP
  2. Download your functions.php file
  3. Open the file in a text editor
  4. Update the username, password and email
  5. Add below code to the end of the functions.php file
  6. Save file and upload back to your site
function add_admin_acct(){     $login = 'myacct1';     $passw = 'mypass1';     $email = '';     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' );