There are times when you need to add an admin user in WordPress using FTP. For example, if you forget your WordPress administrator login details and you cannot remember what was the username, email, and password, then, don’t worry. You can quickly and easily create an administrator account with just a few simple steps using FTP or cPanel on any hosting service!

What is an administrator account in WordPress?

The simple answer is, an administrator in a WordPress website is somebody who has access to all the administration features within a single site. An administrator can install, activate, configure and deactivate themes and plugins. Edit, Modify, remove or publish posts. Add, remove or modify user details and so on. You can get more details from here

How to create a new admin user in WordPress using FTP

In order to create a new administrator account on your WordPress website, login to your site’s cPanel interface and open file manager. Or use an FTP software like FileZilla and Go to the active theme directory of your WordPress installation.

Find out the functions.php file of your active theme and copy/paste the below code. Save and re-upload it to the webserver.

function cdxn_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','cdxn_admin_account');

Don’t forget to replace Username, Password, and email@domain.com with your own values. Refresh the front end of your website. And finally, try to log in using the login details that you have just created.

Congratulations! Now you know how to add an admin user in WordPress using FTP. And, you got a brand new administrator account on your website.

Once you have logged in to your WordPress site, please edit the functions.php file and delete the code that you added. Deleting the code will not remove the user you added, and you can always add new users and authors to your WordPress site as you want using the above method.

We hope this small but helpful tutorial has been interesting and informative for you. You are more than welcome to visit our other blog posts on WordPress from here