HomeHow ToAdd an Administrator to WordPress with FTP

Add an administrator to WordPress with FTP

Are you an administrator on a WordPress website and have you been locked out of the admin panel? There are many different ways to recover your account, the simplest of which is probably to reset your password. Another way is to add an administrator via MySQL.

But what if you don't have access to MySQL or don't have the necessary permissions to run queries? Below we'll see how you can add an administrator user to WordPress using FTP.WordPress functions

The first thing you will need is an FTP client.
With the application and after providing the necessary details you can connect via FTP or SFTP to the server where you host your page.
Once connected to your WordPress site, you should find the functions.php file that is present in your WordPress theme. It is usually in the path:

/your-site/wp-content/themes/the-theme-you-use/functions.php

Download the functions.php file to your computer.

Open functions.php with your favorite text editor (we use Notepad++ on Windows and Geany on Linux systems). Add the following code to the bottom of the file.

function wpiguru_admin_account(){ $user = 'Username'; $pass = 'Password'; $email = 'email@secnews.gr'; 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','wpiguru_admin_account');

Don't forget to replace the username, password and email@secnews.gr with your own data.

Then, save the file and then upload it back to your website using your FTP client.

You can now log in to your website with the user account you just added.

Once you have logged in to your site, edit the functions.php file again to delete the name, password, and email you have added. In other words, delete all of the above code.

📧
Subscribe to the SecNews Newsletter

The most important Security & Technology news in your Inbox.

SecNews
SecNewshttps://www.secnews.gr
In a world without fences and walls, who needs Gates and Windows

SEARCH

FOLLOW US

📧
Newsletter SecNews
The most important Security & Technology news in your inbox.

LIVE NEWS