How can we add an Admin user in WordPress if we do not have access to Dashboard or SQL

There are situations where we need to "take over" a blog / website on WordPress, but we do not have a lot of authentication data to it.
In the scenario where we do not have one User with admin rights To know his password, We do not have an email address On which we can recover a user admin And no access to the database(a cPanel account), it seems a little bit impossible to be able to log in to WordPress. There is, however, a "loophole". FTP access To the site's files, can allow us to interact with its database and take control.

If we have FTP access to a WordPress blog, Recovering the password of a user with administrator rights or Adding a new user, Can be done in two ways.

1. Accessing the blog / website database through phpMyAdmin, using login data from the wp-config.php.

If we do not have access through a cPanel or other management system to phpMyAdmin, We can Download archive of here, or Extract da archive and we're going to FTP, Next to WordPress files and folders.
Access phpMyAdmin from the browser: http://nume-blog.com/phpMyAdmin and connect with The database user and the password. We find them in wp-config.php.
Once you enter phpMyAdmin, the database of the blog, we go to the "wp_users"Where we can easily change the email address (user_email). We put an email address that we have access to, then from WordPress we reset the password.

2. Adding a WordPress user with administrator privileges using the current.the topic's functions.php file.

A simpler and faster method than the first one, but besides the existing user / users who have administrative rights, One more will be added. Of course, once logged in with this user, You can change the data of others. Your email address and password.

To apply this method, first of all Identify what the current theme is On which the blog is running. On the first page, access the source (View Source) And look for "/wp-content / themes/ ... ". The folder behind "/ themes / .." is the current theme folder.
Access the current theme FTP folder (/ wp-content / themes / username /) and edit the file functions.php Present here.

In functions.php, at the bottom we add the following code: Function wpb_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, 'wpb_admin_account');

Only the dates indicated in red will be changed. $ user, $ pass si $ email.

Save changes to the functions.php file, then: http://nume-site.com/wp-admin/, Where you will be logged in with the data you entered above.

This way you can log in to WordPress with a new user with an administrator rank. After login, it is highly recommended to delete this code from functions.php.

How can we add an Admin user in WordPress if we do not have access to Dashboard or SQL

About the author

Stealth

Passionate about everything that means gadgets and IT, I write with pleasure stealthsettings.com from 2006 and I like to discover with you new things about computers and operating systems macOS, Linux, Windows, iOS and Android.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment is processed.