Sometimes you may forget your WordPress login details like username and password. At that time you can’t log in to the admin area. But for developers, they need to create a user in the database occasionally to access the website. So they will add the users by adding an admin user using MySQL. However, many of them are not comfortable with MySQL and also the processing is too slow. So you can easily add a WordPress Administrator User by using the following method. Here we will show you to add a WordPress Administrator User via FTP which is faster than the other methods.

Adding a user Via FTP:

For this, you should have an FTP client. Now connect your WordPress site to your FTP. Next, you should navigate to the functions.php file which is located in your current theme’s folder. You can find your current theme folder in themes folder which is available in the wp-content folder. Then right-click on the functions.php file and download it to your computer. Once the download process has done, open the file on your computer. Now you need to add the below-mentioned code at the bottom of the file.

function wp_admin_account(){
$user = ‘Username’; //Replace your username with your own value
$pass = ‘Password’; //Add a password with your own value.
$email = ’email@domain.com’; //Add an email address which is not exist already.
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’ ); //Setting the role for the user that you’ve entered.
} }
add_action(‘init’,’wp_admin_account’);

Save the file and upload it back to the WordPress site through FTP. You can now log in with the user account that you’ve entered it. Once you have logged in to the website admin area, delete the code you added in functions.php. It will not affect the user you have added.

Note: You can access the file with File Manager also instead of FTP by navigating to the exact path.

We hope that this article will help you to add a WordPress Administrator User to the WordPress site using FTP. For more information, follow us on Twitter and Facebook. For video tutorials, subscribe to our YouTube channel “ServerCake India“.

Categorized in:

Tagged in:

,