How To Create New WordPress Admin User Account Via FTP

Creating a new user account on WordPress is a piece of cake. All you have to do is head over to the Users admin page, where you can create your new account.

This takes no more than a few seconds. Once you’re done, you will be ready to log in with your username and password.


If, however, you lose access to your WordPress admin account, what do you do?

Do you panic, make a bunch of calls, or close your eyes and take a couple of deep breaths? Or do you stay calm, knowing that we always have the perfect solution for you?

The latter, of course! We have a function to save your admin life in this very situation.

[bctt tweet=”Whatever the reason may be for the loss of control over your #admin #account, you can retake charge in no time.”]

Create Admin account via FTP

Sometimes, you may be able to access only your FTP server with the HTTP server remaining out of reach. In this case, you have to create a new admin account. This, although a rare case, can be rectified with the given function.

To create a new account outside the WordPress admin environment, all you need is FTP access to your WordPress site. Being the admin, you should have the necessary information to log in to your server.

There are some actual places where you can place a piece of code, and it can create a new admin account for you, like function.php in your themes. Any code added to function.php gets executed while loading the WordPress theme.

The step-by-step guide illustrated below shall take you through the process of creating a new user account via FTP:

Messing with code feels too complicated and time-consuming? We hear you! Try the Emergency Recovery Script for WordPress. It’ll get you better and faster results than messing with code.
    1. Open the FTP client and connect to your account.
    2. Navigate to wp-content/themes
    3. Open the folder of the theme that is currently in use.
    4. Look for the functions.php file and edit it.
    5. Copy the following function and paste it into the file.
function create_admin_account(){
$user = 'Username';
$pass = 'Password';
$email = '';
//if a username with the email ID does not exist, create a new user account
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
//Set the new user as a Admin
$user->set_role( 'administrator' );
} }
  1. Change the username, password, and email ID.
  2. Save the changes.

The new email ID, password, and username must be unique, or the function may not work correctly.

After saving the changes, you may navigate to the WP login panel, and log in with your new information. Once you have successfully verified your account, you can delete the function from the functions.php file.

The given function creates an admin account, but it can create an account with a user role just as easily, with only a few modifications. All you need to do is change the role in the 8th row of the code to whichever user role you create (author, subscriber, contributor, etc.)


If unfortunately, you lose your admin account, you shall end up losing all posts that had been written under that name. It is essential, thereby, that you keep a backup which can easily be retrieved if needed.

Once you logged in with your new Admin user ID, you can reset the password of the old admin account. This way you do not lose any data.

Consider this an important reminder that must NOT be overlooked: If you don’t already have a backup, create it immediately. You may also want to see How to Hack Into a Wordpress Website, The Complete Guide,  to see how to regain access to your WordPress account, to which you have the right to edit, access and administrate, in the event, you lose access.

Read more about the author .

Save 40%

On monthly and annual plans

Lifetime Deals

Only during BF sales!




We won't spam you. Unsubscribe any time.

Wait! Before you go!

Get 10% discount for any WP Security Ninja plan!


Subscribe to our newsletter for new releases, discounts and general WordPress Security news. Sprinkled with other interesting stuff :-)

WordPress Turns 20: Save 20% Now!



Code valid till June 26th 2023

10% OFF

Subscribe to our newsletter

* We do not spam or share your email

Discount on any Security Ninja plan

and get

Hi and welcome back :-)