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. Required fields are marked *

About the author

Rik Kendell is a developer, designer and writer in Leeds, UK, specialising in responsive WordPress websites. With over 10 years experience in the industry, Rik has worked on award-winning teams at agencies, in-house and as a freelancer. Rik has worked with clients ranging from the NHS, Sky and Skipton Building Society to McDonalds, Lamb’s Navy Rum and Crabbie’s Ginger Beer.

Outside of work Rik is also a keen writer, an amateur woodworker, gamer and foodie. His blog posts, reviews and Tweets have been published by the BBC, the Evening Standard, the Guardian and the Independent. He has written guest posts for a number of agencies and industry websites.