Emergency WordPress access

If you do a lot of WordPress development work, you're bound to receive WordPress database sometimes that you don't have an admin account for. We at OrangeValley at least, do have that issue. We usually test, if possible, on a database the client provides us with. We used to have to go into the database and change an existing user, or add a new one by hand, and well, that wasn't too optimal.

Quite a while ago I came across a script (mentioned before in a WordPress Scripts post) called emergency.php that partly solved this issue for us, but it was not really what we'd call the answer to all our problems. It sent out an email to the admin saying the password for the admin was changed, something we actually didn't want to happen, because we couldn't change the email in the same script. It also didn't allow us to add a new user, and didn't have any security restrictions, so leaving it out in the open was quite a horrific experience.

This morning, when I ran into this issue for the gazillionth time, I decided it was time to fix it. So I built a new user manager script, still dubbed emergency.php because basically that's when you use it. It looks like this:

As you can see it asks for the database password. If you have FTP access, that's easy enough to come by, but it prevents other people from messing up your site when you accidentally leave the file online. Once you've selected a user or chosen to add a new one, and you've entered the correct database password, you'll get a screen like this:

Click for larger version

Clicking "Add user" will add the user to the database, or, if you're editing an existing user, update it in the database. Easy does it! You can download the file here, enjoy!

Update June 29th 2010: We've patched several issues within the file, fixing the empty roles dropdown, not being able to include the required files and some notices. Download the latest version here, links above have been updated too.

41 Responses to “Emergency WordPress access”

  1. Such a brilliant solutions. Thumbs up!

    Suggestion:
    If you could add CAPTCHA on the User Manager page, that would be awesome as it might prevent some nasty things to try the database password several times. Possible?

  2. This looks really handy Joost. I have got clients in the past to install the PHP MyAdmin WordPress plugin but this will be much easier. Top work as usual!

  3. Thanks for this but had to figure out where to upload it to myself!?

  4. Uploading the .zip through the plugins "Add New" menu returns "This plugin does not have a valid
    header."

  5. Awesome! Will achieve a copy of this for when the time comes!

  6. Awesome sir. This will come in handy!

  7. In support I have a similar tool: It comes with auto-configuration by looking up needed values from the configuration file, creates a new admin-user on a click and then offers to automatically log you in on a second click. WordPress Backend openes in a new tab and voila!

    As a security measurement, it will automatically locks itself down, so an attacker can not open the file after the support personnel requested it. Next to this is has a self-delete button as well, so you can clean up afterwards.

    It works well in those cases where you have FTP access but the customer did not tell you about the backend password.

    Needs PHP 5 and works with PHP 2.8 and above I think (those versions which do use PHPASS not MD5 as hashing algo in the database). Let me know if this sounds interesting, I think I can put this online, it's licensed under AGPL.

  8. Making any thing in hurry is not good and makes certain problems for others but your approach seems quiet beneficial and applicable...

  9. great stuff Joost

  10. Awesome idea / script! I've tried adding a new user but can't select a user role (drop down list is blank) and user has no role in wp-admin.

    Am I missing something??

    Cheers Joost

  11. Couldn't it have been easier if you would have load WordPress environment and then used WordPress functions only?

  12. Nicely done! Thank you :)

  13. Thanks for a handy script. I've run into similar situations and this is much easier than diddling around in the DB.

  14. Does this open the site up to being hacked?

    • For the wpaaa.php (wordpress access all areas) I have some other approach then Yoast. The first person who requests the file gains access. This is normally the person who just uploaded the file to gain access to the Blog. Everybody else then will only get a 401 - gone message. I named this a lockdown mechanism. It's very handy because you do not need to lookup any passwords while doing a secure approach. Perfect for a quick support job.

      So wpaaa won't leave the Blog open to attacks while giving the uploader full control. In case this mechanism does not work, wpaaa automatically blocks it's usage.

      Next to that, the script does not link external resources like images, so it works in closed environments as well. Maybe I should write a better review of it... .

  15. I used this script on a site for a new client. Worked perfectly! (Then I deleted the file from the server -- just to be safe.)

    Thank you Joost for all you do for the WordPress community!

  16. Thanks for this scripts. I was known to go into MYSQL database via phpmyadmin (Plesk in my case) and change the encrypted password and keep copy of the old password. Once work done, change old password in database itself...

  17. Well this is definitely many times better then the method I always use:
    Go to the database (phpmyadmin) change the email of the user to your own email, hit the forgot password option and you're in. ( Change the email back to client and mail him the new PW :) )

    Thanks Joost!

  18. I am using WP 2.9.2 and have tested this script on two of them, and it does not work for either of them. it appears to break after loading wp-blog-header.php, but then seems to break while trying to load wp-admin/includes/template.php. all the required files do exist. any idea as to the problem or solution for this?

  19. Your product just saved me from having a site stolen! Fantastic and took 3 minutes to use.

  20. This will save me time on client sites. Thanks so much for sharing this useful script!

  21. Excellent script. Just what I was looking for. Great work.

  22. I just experienced what James Morrison did, about the roles dropdown not being filled. If I edit a pre-existing user, the dropdown is filled with the proper roles, but if I attempt to add a user, it is blank. I looked up the functions being used, and cannot find a reason for it to not work.

  23. Finally (as promised) I was able to put up a post regarding WP Access All Areas. -> http://hakre.wordpress.com/2010/05/11/wpaaa-php-wordpress-access-all-areas/

    It contains a full review and screenshots.

Comments closed, if you feel you have something to say:
drop me a line.

9 Trackbacks to “Emergency WordPress access”

  1. Emergency WordPress access | WPLover - Mon, April 26th, 2010 at 00:27
  2. Cómo recuperar la contraseña de tu blog por ftp - Mon, April 26th, 2010 at 15:38