The normal process of resetting the password is quite simple in WordPress.We click forgot password link in our login page, enter our email address and then click Get New Password button. We get an email with a link to reset our password.
But there may be cases when the reset password mail functionality is not working as expected. In this case, WordPress provides alternative methods to change our forgotten password. In this blog, we will discuss in detail the process to reset our WordPress admin password using the FTP client. FTP is a simple method used for transferring files between our computer and the server. Although this does not require programming knowledge it is recommended to have a basic understanding of PHP before proceeding with the below steps.
Step2: We have to navigate to our current active theme folder which under wp-content.
Step3: Inside the current theme folder we have to locate functions.php file and download it. I am using the Genesis theme for blogtriangle along with the default genesis-sample child theme. So for me the functions.php file would be under public_html/wp-content/themes/genesis-sample folder.
Keep a backup of this file for being on the safer side to prevent any unexpected issues.
Step4: In the downloaded functions.php file enter the text
wp_set_password( ‘password’, ‘username’);
in the line just after the <?php text.
This line is actually meant to reset the password. We have to replace ‘password’ text inside the bracket with our new required password and ‘username’ text with our existing username. In case we know the User Id and not the username then we can use the below code instead of the above-mentioned one. The value of User Id for the default administrator account is 1. So, in that case, the code would be like
wp_set_password( ‘password’, 1);
For demonstration purposes, I am using 123456 as my new password. My existing username was admin. Hence for me, the code would be like as shown in the below screenshot.
Step5: Now save the changes in the functions.php file and upload it back to the server. We can now try to login by using the new password and the existing username. The login page just reloads without redirecting us to the admin dashboard page. This indicates that our password has been reset. Do not try to login again as this will again reset the password.
Step6: We can now use FTP client again and download the functions.php file that we have modified in Step 4.Revert the changes to functions.php file. Just remove the line wp_set_password( ‘123456’, ‘admin’); that we have added before.
Step7: Save the file and upload it back to the server. We can now login to our website as usual with the new password.
Thus in a few simple steps, we have reset the WordPress admin password using FTP.
Note: The password mentioned here is just for demonstration purposes only. Once we login successfully to our admin dashboard we have to change the password to a strong one. The password should have both upper and lower case letters together with numbers and special characters. This is essential to ensure our website security.