Localhost WordPress Password Reset

25th April 2014

Reading Time:

If you’re running WordPress on localhost, you’re unable to reset your password – I found this out the hard way recently. Luckily, there’s a really easy way to reset your password (or change it to anything you like). This also works on live sites, provided you have access to the files through FTP or similar.

  • Go to the folder for the theme your site is currently using: wp-content/themes/[theme-name]
  • Open functions.php
  • At the top of the file, just inside the opening php tag, add wp_set_password('password',1); and save
  • Log-in as the admin using ‘password’ as your password
  • The page will reload. This changes the password to whatever you have defined in your functions.php file
  • Remove wp_set_password('password',1); and save again, and log-in as normal, using the reset password

Explanation: wp_set_password([string], [uid]) is a function defined in the WordPress core which changes the password to [string] for the user who’s user ID (uid) is 1, usually the admin/default user.

Share this post

Leave a Reply

Your email address will not be published.