If you’re locked out of WordPress and can’t reset your password, the official docs list several options that allow you to access your administrator account again. But what if you want to create an entirely new admin user?
When developing a WordPress site, I typically create an admin user for the development team, set to a general email address, and then another user for the client. That way, the client can manage their own password and reset it when necessary, and we will still will have access for upgrades and changes. For blogs that I have FTP access to, but no working WordPress password, I threw together the following script to create admin users.
How to Use
- Change the configuration variables for username, password, and e-mail
- Save PHP file in your root WordPress directory
- Access the file via your web browser.
- You will see a message with the results. If successful, go ahead and delete the file from your server.
- Log in to WordPress!
Full Source Code
This was originally tested with WordPress 3.1.2. It should be working with all latest versions (3.8+):