How To Add An Admin User In WordPress Using FTP

How To Add An Admin User In WordPress Using FTP

Due to various reasons, you might get locked out of your WordPress admin. You may forget your username and password of your site  or it may have been hacked and the current admin user account has been deleted. You want to make some changes to your site and all you can do is nothing. In this tutorial, you will learn how you can add an admin user to your WordPress site using FTP application.

Prerequisites

  • Domain Name
  • FTP Application (filezilla, cyberduck)
  • FTP login credentials
  • Text Editor (Notepad, Sublime Text)

Step 1:

Connect to your WordPress site using a FTP client

like FileZilla, Cyberduck. You will need your hostname, username & password to connect through a FTP Client application. You can access these information from the cPanel of your host.

How To Add An Admin User In WordPress Using FTP

Step 2:

Once you are connected to your WordPress site from FTP client, you need to get inside your public_html directory. You will find wp_content folder. Inside the folder go inside Themes and click your current theme folder. Inside the folder

you will find functions.php file

.

Download this file and open it using text editor like notepad or sublime.

How To Add An Admin User In WordPress Using FTP

Step 3:

Add the following piece of code to the functions.php file  and save the file
functionwpb_admin_account(){
$user = 'Username';
$pass = 'Password';
$email = mail@example.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');

Here, You need to replace the Username, password and the email address with your own.

Step 4:

After saving the changes, upload the functions.php file to your WordPress site using FTP and replace your current file

. Now you can log into your WordPress admin panel using the newly created username and password.

Conclusion

By following the above steps, we can easily create a new admin user for our WordPress site using FTP client. Once we login with the newly created username and password, we can delete the code we added in the functions.phpfile.

Check out the top 3 WordPress hosting services:

A2 Hosting
$1.95 /mo
Starting price
Visit A2 Hosting
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.8
  • Pricing
    4.0
IONOS
$1.00 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.3
HostArmada
$2.49 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.0

How To Set up a VSFTPD Server on a CentOS 7 VPS or Dedicated Server

Brief Description FTP is usually insecure exposing clear-text passwords, userna
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How To Set up a VSFTPD Server on an Ubuntu 16.04 VPS or Dedicated Server

Brief Description FTP data is usually insecure since information (usernames, pa
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to Connect FileZilla to Manage Your Website using FTP

Most of the people rely on the direct access to the cPanel of their web hosting
4 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to configure FlashFXP FTP client

This article shows you how to configure FlashFXP, a fast, secure FTP client that
2 min read
Idan Cohen
Idan Cohen
Marketing Expert
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top