Creating a new WordPress administrator user is easy if you have access to your wp-admin panel. Sometimes, you might not have the privilege to your website or on a multi-author site.
There may be a case when you get a white screen of death, and you might require a new user account. And you know that only an administrator has the complete access to a WordPress website.
When having multiple users on the single site, you choose the different user roles. But when you’re the only one managing your WordPress site, you need an administrator account to fix an issue.
Suppose, you forget your login credentials and you also don’t have access to your email address. At such a situation, you require to create a new WordPress administrator user, which is possible using FTP.
If you have access to cPanel, you can also accomplish the same task using it. But this tutorial is about using FTP, which is more comfortable than the cPanel method.
Edit the functions.php File to Add a New WordPress Administrator User
I hope you know the process to connect your FTP account with your web server using Filezilla. Almost every company offers you to create an FTP account while installing WordPress.
If you already have an account, you can use it, or create a new one. For which, you need to use cPanel. But, if you already have an account, follow the steps.
Note: If you have multiple websites on the same server, you might need to open its folder.
Step 2:
The lower box in the right corner shows the files and folders,
Step 3:
You may know that wp-content stores all the plugins, themes, and media files. From here, you need to
Step 4:
You can see all active and inactive WordPress themes present on your website.
Step 5:
Scroll down, and
Step 6:
A popup appears to select the text editor. By default, it picks the default text editor of your computer.
I prefer to use the default text editor by clicking on the Ok button.
Step 7:
Now, you can see the functions.php file in the text editor you choose.
functionnew_admin_account(){ $user = 'Username'; $pass = 'Password'; $email = 'email@domain.com'; //If a username with the email ID does not exist, create a new user account if ( !username_exists( $user ) && !email_exists( $email ) ) { $user_id = wp_create_user( $user, $pass, $email ); $user = new WP_User( $user_id ); //Set the new user as an Admin $user->set_role( 'administrator' ); } } add_action('init','new_admin_account');
Add this code to the file.
Note: Don’t forget to replace the default Username, Password, and Email with your login credentials.
Save the file, and you’re good to go. Now, you can log in to your WordPress website using new credentials. Congrats, you have successfully created a new WordPress administrator account for your site.
Dealing with the common WordPress issues can be overwhelming, but when you know the alternatives, everything becomes convenient.
You may need to create a new user in many situations. Losing the login credentials is one of the most common scenarios, I forget them all the time.
I am sure, you may also have used a web hosting which didn’t provide access to cPanel.
Conclusion
Either you have the privilege or not, you can create a new WordPress administrator user using FTP. Within no time, you can solve your problem of not logging in to your WordPress site.
I hope you can understand the concept and use an FTP server to accomplish such a task.
Check out these top 3 WordPress hosting services:
- Do you need the best wordpress hosting? Check out for our recommendations by clicking here.