How to Use FTP to Create a New Admin User in WordPress

add an admin user in WordPress using FTP

How can you create a new WordPress user account if you can’t log in, to begin with?

WordPress continues to dominate the content management software landscape. Over 65% of all CMS sites use WordPress to power their platforms. That’s 42.8% of all websites worldwide.

WordPress for business is especially popular as the system is easy to use but is low-cost and scalable. But what happens if you can no longer access the administration area?

This article adds to our WordPress tips posts by sharing how to add an admin user in WordPress using FTP.

Learn how the platform stores user account information. Find out how to manipulate your theme’s function file to generate a new profile. See how to back up your files and why you need a professional team to maintain your website.

Read on to discover how to use FTP to reclaim your business WordPress site.

Understanding WordPress User Accounts

WordPress offers four types of user accounts that perform specific actions:

  • Administrator – has full access to WordPress and can add/edit/delete data and site maintenance
  • Editor – has total control over website content but not plugins, etc.
  • Author – publish and edit their own posts and WordPress profile
  • Contributor – restricted author role that cannot delete published posts
  • Subscriber – can only create and edit their own profile and comment on posts

WooCommerce adds to this list with Customer and Shop Manager roles. Multi-site owners also have a Super Admin role that can control all of their connected websites.

How to Create Admin Users Using WordPress

The easiest way to create a new Admin user is through the WP admin section.

Log in to your WP site, e.g. https://www.yoursite.com/wp-admin using an Admin role user. Click on the Users link on the left, then Add New. Enter a username, email, first/last name, language, and password. Then select Admin from the user roles and click Add New User.

Problems occur when you cannot access the admin section.

Perhaps you have lost your login details, or worse, you have been hacked, and the hacker has removed your account. Maybe the site refuses to send an email reminder and effectively blocks you.

Alternatives to Creating WordPress Users

Thankfully, you have several options to override the login facility and create new access accounts.

As all of the user information is stored in a MySQL database, you can use phpMyAdmin to alter the data. Read our extensive tutorial on adding Admin users to WordPress using a database to achieve this.

Yet, not everyone has access to phpMyAdmin. Plus, editing website data should only be performed by a professional.

That’s where adding an admin user in WordPress using the FTP solution becomes invaluable.

Using FTP to Access WordPress Files

FTP or file transfer protocol enables web developers to set their websites ‘live’.

The process copies files from a local computer and transfers them to a web server. In the case of WordPress, that means uploading system and configuration files.

Using FTP means you can override in-built WordPress functions to perform specific tasks. That includes creating new accounts.

Creating a New Admin User via FTP

Creating a new Admin user via FTP involves editing your theme’s function file and adding some code.

Follow the 6 steps below but be careful.

Editing system or theme files incorrectly can result in your site crashing. Please speak to a team of WordPress experts like Thrive WP before touching them.

  1. Install FTP Software

There are lots of free FTP applications that you can use to access your WP site.

FileZilla is a fast and robust FTP client that can handle lots of simultaneous transfers. It works on Windows, Mac, and Linux on 32 or 64-bit platforms.

Install the software and enter your FTP details:

  • FTP address – usually ftp.yourwebsite.com
  • Username/Password – created in your web hosting control panel

Once connected, you should see a list of wp-* files and three folders: wp-admin, wp-includes, wp-content. The latter holds your site’s images and themes.

Alternatively, you can use your website host’s file manager app to download and upload files.

  1. Download Theme Files

The right side of the screen is your live site. The left panel shows your computer’s directories.

Navigate to: /yourwebsite.com/wp-content/themes/your-theme/

You will see several files, including functions.php. This is the key file to download. Drag it to the left of the screen to copy it to your hard drive.

  1. Edit Theme Function File

The functions.php file might be empty, or it could contain code that overrides WordPress’s core functionality. You can use a basic text editor like Notepad to edit the contents.

Make sure to backup this file before continuing! Then scroll to the very bottom of the page and copy/paste this code:

function wpb_admin_account(){
$user = 'Username';
$pass = 'Password';
$email = 'email@yourwebsite.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');

Notice the ‘Username’, ‘Password’, and ’email@yourwebsite.com’ information. Edit these details to reflect your new Admin user. You can also change the role here if required.

  1. Upload Edited File

Save the file and open FileZilla. Drag the edited functions.php file from the left of the screen to the live server on the right.

Please note that FileZilla will ask you if you want to overwrite the existing file. Click OK to agree.

  1. Log in to WordPress Admin

Visit your WordPress admin and log in with the new details. You should now have access to all of your settings and posts.

  1. Remove Edits and Upload

Return to the functions.php file and delete the code you’ve added. Re-upload it using FileZilla. This will ensure that WordPress does not try to add the same new user again.

More WordPress Tips and Advice for Business Users

In our series of WordPress tips, we have explained how WP user accounts work and how to edit them.

If your current login doesn’t work and you cannot use phpMyAdmin, adding an admin user in WordPress using FTP is essential. Editing your theme’s function file and uploading it via FTP will create a new profile within seconds.

However, most business owners do not have the time or skillset to achieve this. That’s why our clients rely on us to manage their sites on their behalf.

Thrive WP is an award-winning WordPress maintenance and support provider based in the UK.

Our monthly care packages take away the burden of updating plugins, themes, and core files. We also perform daily backups and can fix user accounts. The result is that you can carry on with your business without worrying about your website.

Contact us today to see how our team of WordPress professionals can assist you.

Share