If you are locked with WordPress Admin, Don’t worry we have a key to
get back to the WordPress. In this blog, I will let you know How to add
New Administrative Account using FTP/function.php
If you have only access to FTP or files and you can get logged in via this master key. This trick will allow you to enter without the Database.
In some cases, hackers hack the website and remove the master/admin user at that time you can easily add the new admin user.
Save the file and go to FTP client.
Go to the Admin Login area of your website and now you can log in with just added a new user.
After logged in you may remove the above code, you are registered as new admin and you can find it via wp_users table.
We hope this blog helped you learn how to add an Administrator user to WordPress using FTP.
You may also want to see How to make Customize Login Page in WordPress.
If you liked this article, You can also find us on Twitter and Facebook.
If you have only access to FTP or files and you can get logged in via this master key. This trick will allow you to enter without the Database.
Why do you need to add WordPress Admin using FTP?
Sometimes you may forget your WordPress username or Email and you are not allowed to go admin area. You may take help of WordPress database, go to users table and update the password, But you may not unable to connect it with phpMyAdmin.In some cases, hackers hack the website and remove the master/admin user at that time you can easily add the new admin user.
How to add New Administrative Account in WordPress using FTP
First of all, connect your FTP account. After got connected, find the function.php of your active theme. Example: www.yourdomainname.com/wp-content/themes/my-current-theme/function.php, Right click the file and select View and Edit option and add below code into the file.function wp_add_admin_account(){
$user = 'my_username'; //set your suitable username
$pass = 'my_password'; //set your suitable password
$email = 'email@myemail.com'; // your email id
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email ); //create new WordPress user using above fields
$user = new WP_User( $user_id ); //get the object of new user
$user->set_role( 'administrator' ); //set the role as administrator
}
}
add_action('init','wp_add_admin_account');
Don’t forget to replace my_sername, my_assword, and email@myemail.com with your own values.
Save the file and go to FTP client.
Go to the Admin Login area of your website and now you can log in with just added a new user.
After logged in you may remove the above code, you are registered as new admin and you can find it via wp_users table.
We hope this blog helped you learn how to add an Administrator user to WordPress using FTP.
You may also want to see How to make Customize Login Page in WordPress.
If you liked this article, You can also find us on Twitter and Facebook.
Thanks for the tutorial!
ReplyDeleteThat was incredibly illuminating
Check Your Wordpress Here
Keep yourself warm in the winter. Although many people suffer from allergies in warm months, a lot of people still have problems in the winter. play bazaar satta king
ReplyDelete