Lost or forget admin user credentials is really frustrating. Without Admin user you can’t access WordPress Admin area. But the good news is, there is a solution if you have the FTP access. If you don’t have FTP access then go to your Cpanel access and make an FTP account for your website.
In this artical we will show you how to add an Admin user in WordPress by using FTP step by step.

How to add an admin user in WordPress by using FTP

Why may you need to add an admin user in WordPress by using FTP?

There are some common scenarios:
1) Sometimes it may happen that you forget the username or email address and password for admin user and without admin credentials, you can’t login in the admin area.
2) Sometimes the site may hack and all admin credentials may be deleted by the hacker. In that case, you need to add an admin user to access the site.
So you need to add an admin user by using FTP or MySQL. There is a step by step guide that how you add an admin user by MySQL database.
In this article, we are gonna learn that how to add an admin user in WordPress by using FTP.
If you have FTP access then go to any FTP client software like Filezilla and connect the server with FTP credentials. If you don’t have FTP Account then go to your hosting Cpanel and make an FTP account.
once you connect your WordPress website then locate your active theme and in the theme select the functions.php file.

 

The location would be like this
yourdomain.com/wp-content/themes/your-active-theme/functions.php

Click right button and select view/edit option. It will download and view with active IDE.
To add an Admin user in WordPress add below code in your functions.php file. It is good practice that, add the code at the end of the file to identify easily when you want to delete it.

function wp_expert_add_admin_user(){
$user = 'Yourusername';
$pass = 'yourpassword';
$email = 'email@yourdomain.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','wp_expert_add_admin_user');

You are done. Don’t forget to change the username and password according to your choice.
Now go to your WordPress site admin access area usually is to www.yourdomain.com/wp-admin/ and enter the username and password ( which you have just inserted in the functions.php file )

After successfully logged in, edit your functions.php file. Remove the above code which you have just inserted. Deleting the code will not remove your admin user. So don’t forget to remove the code from the functions.php file.

So, now you know how to add an admin user in WordPress by using FTP.
We hope this article helped you to learn how to admin user in WordPress. To get the fresh content of WordPress stay connected with us.

Share the post on your social media. Find us on Facebook and Twitter