How to Add a WordPress Admin Account Using FTP Having your WordPress webmaster account locked is frustrating. Recently, one of our readers asked if it was possible to add an admin user in WordPress using FTP. Yes of course. In this article, we will show you how to add an admin user in WordPress using FTP.
How to Add a WordPress Admin Account Using FTP
Why you might need to add an admin user in WordPress using FTP?

Sometimes you might forget your username or email address on your WordPress website and not be able to log in to the admin area, it could also mean that you have been kicked out of the site’s admin area for a reason. some number of reasons.
One way to add an admin user to a WordPress database using MySQL. But you may not be able to connect to phpMyAdmin or don’t want to run MySQL queries directly or you don’t want to do complicated steps.
Some users may have their websites hacked and admin accounts deleted. In that case, adding an admin user using FTP can quickly restore your access to the WordPress admin area.
Let’s see how you can easily add admin users in WordPress using FTP.
Adding an Admin User in WordPress Using FTP
The first thing you need is an FTP Client. After connecting to your WordPress site, you need to locate the functions.php file of your WordPress theme. It will be in a location like this:
/yoursite.com/wp-content/themes/your-current-theme/functions.php
Right click on the file and select download. Your FTP client will download the functión.php file to your computer.

Add a WordPress Admin Account
Open the file you just downloaded on your computer with a plain text editor like Notepad . Now you need to add this code at the bottom of the file.
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');
Don’t forget to replace Username, Password and email@domain.com with your own values.
Next, save the file and then upload it back to your website using the FTP Client.
You can now access your WordPress site login area and log in with the user account you just added above.
If you can access it using File Manager on your hosting’s admin page, you can also do the same to edit the functions.php file
Once you are logged in to your WordPress Web site, please edit the functions.php file and remove the code you added . Removing the code will not remove the users you added, you can always add new users to your WordPress site.
Don’t forget to leave a comment below if you have any questions or problems, we and other readers are here to help.
Link : https://chiasedev.com/huong-dan/them-quan-tri-wordpress-qua-ftp/