How can we add a user with a WordPress Administrator rank using FTP

A less fortunate script is to us Forget the password User with rank "admin"Of the blog created with WordPress, to We no longer have access to the email address That would help us Reset password, And that the situation would be even more complicated, it would be We have no access to the database either. MySQL.

In this scenario, the only way we can resume blog administrator rights is to create a new user with a WordPress Administrator rank. With this new user we create, we can reset our user password or use it with all the administrative rights.

How can we add a user "admin" to WordPress, with the help of FTP access

All we need is to We have access to the site's files and we can edit them. To do this we need to FTP access data. User FTP, password Afferent and IPSite / server address FTP. An FTP client to connect to. FileZilla. Free and easy to use.

After we connect to FTP, we're going to edit the file functions.php. It can be found in: wp-content / themes /theme-current/.

Adding in functions.php the 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' );
} }

Edit your $ username, $ pass and $ email, replacing "Username", "Password" and "[email protected]" in the code above. Once you've added this feature, save the changes and visit the blog login page. / wp-admin / or /wp-login.php by default.

After logging in with the new data, do not forget to go back to the functions.php file to remove the code added above.

The newly created user will be saved in the database.

How can we add a user with a WordPress Administrator rank using FTP

About the author


Passionate about everything that means gadget and IT, I am pleased to write on from 2006 and I love to discover new things about computers and macOS, Linux operating systems, Windows, iOS and Android.

Leave a Comment