Hey folks! Ever locked yourself out of your WordPress site? It happens to the best of us—maybe you forgot your password, got hacked, or a plugin went wrong. Don’t worry! You can add a new admin user right through FTP without needing to log in. This trick saves the day and gets you back in control fast. In this guide, we’ll walk you through it step by step. It’s simple, even if you’re not a tech whiz. Let’s get started!

Why Add an Admin User via FTP?

Sometimes, you can’t access the WordPress dashboard. Common reasons include:

Using FTP lets you edit files directly on the server to create a new admin account. It’s a quick fix that works when other methods fail.
0

What You’ll Need Before Starting

To follow this tutorial, make sure you have:

If your host has a built-in file manager (like Bluehost does), you can skip the FTP client and do it there too.

Step-by-Step: Adding the Admin User

Follow these steps carefully. We’ll edit the functions.php file in your theme to run a small code that adds the new account.

  1. Connect to Your Site via FTP: Open your FTP client and enter your details to connect. Once in, go to your WordPress folder—usually /public_html/ or similar.
  2. Find the functions.php File: Navigate to /wp-content/themes/your-current-theme/. Right-click functions.php and download it to your computer.
  3. Edit the File: Open the downloaded file in your text editor. Scroll to the bottom and paste this code:

function wpb_admin_account(){
    $user = 'Username';
    $pass = 'Password';
    $email = 'email@domain.com';
    if ( !username_exists( $user )  && !email_exists( $email ) ) {
        $user_id = wp_create_user( $user, $pass, $email );
        $user = new WP_User( $user_id );
        $user->set_role( 'administrator' );
    }
}
add_action('init','wpb_admin_account');

Change ‘Username’, ‘Password’, and ’email@domain.com’ to your own info. Pick a strong password!

  1. Upload the Edited File: Save the changes and upload it back via FTP. Say yes to overwrite the old file.
  2. Log In to WordPress: Go to your site’s login page (like yoursite.com/wp-admin) and use the new username and password. You’re in!

That’s it for getting access. But don’t stop here—clean up next to keep things safe.

Cleanup: Remove the Code After Use

Once you’re logged in, go back to FTP:

Why? The code runs every time the site loads, which isn’t needed anymore and could cause problems if left there. Removing it won’t delete your new user.
0

Tips and Warnings for Safety

These steps should work on most setups, but if your site is hacked, consider a full security check after regaining access.

Final Thoughts

Locking out of WordPress can be stressful, but adding an admin user with FTP is a simple rescue. It takes just minutes and no fancy tools. Now you’re back in business, ready to update your blog or fix issues. Remember, strong passwords and regular backups prevent this from happening again.

Happy WordPressing!

Leave a Reply

Your email address will not be published. Required fields are marked *