Are situations where we need to “take over” A blog / website on WordPress, but we do not have much authentication data on it.
In the scenario we have no user with admin rights to whom we know the password, We don't have an email address that we can recover an admin user and no access to the database(a CPanel account), it seems little impossible to be able to authenticate in WordPress. There is, however “ported”. FTP access At the files of the site, it can allow us to interact with its database and take control.
If we have FTP access to the files of a blog on WordPress, Recovering the password of a user with administrator rights or adding a new user, can be done in two ways.
1. Accesarea bazei de date a blogului / website-ului prin phpMyAdmin, folosind datele de conectare din fisierul wp-config.php.
In cazul in care nu avem acces printr-un cPanel sau alt sistem de management la phpMyAdmin, putem descarca arhiva de here, o dezarhivam and o urcam pe FTP, langa fisierele si folderele de WordPress.
Accesam phpMyAdmin din browser: http://nume-blog.com/phpMyAdmin si ne conectam cu user-ul bazei de date si parola. Acestea le gasim in wp-config.php.
Odata intrati in phpMyAdmin, la baza de date a blog-ului, mergem la tabelul “wp_users” unde putem schimba foarte usor adresa de e-mail (user_email). Punem o adresa de e-mail la care avem acces, apoi din WordPress facem resetarea parolei.
2. Add a WordPress user with administrator rights, using the function.php of the current theme (theme).
A simpler and faster method than the first, but which besides the existing user / users who have administration rights, one will add one more. Of course, once authenticated with this user, You can change the data of others. E-mail address and password.
To apply this method before all Identify what is the current theme on which the blog runs. On the first page access the source (View Source) and look “/wp-content/themes/…”. The folder present after “/themes/..” is the folder of the current theme.
We access through the FTP Folder Current theme (/WP-CONTENT/THEMES/NAME_TEMA/) 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 protected]';
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 data indicated with red will be modified. $user, $pass and $email.
Save the changes of the file functions.php, then access: http://nume-site.com/wp-admin/, where you authenticate with the data entered by you above.
This way you can authenticate in WordPress with a new user with administrator. After authentication it is very advisable to delete this code from functions.php.