← ServerPilot Docs

How to Reset a WordPress User Password

If you need to change a WordPress user's passwords but are unable to log into the WordPress dashboard, there are multiple ways you can set a new password.

Choose the method below that's easiest for you.

Resetting Your WordPress Password Using the WP-CLI

To set a new WordPress password using the WP-CLI, SSH into your server as the app's system user and change directory to your app's public directory.

cd apps/APPNAME/public

Run the following command. Replace USERNAME with the name of your WordPress account. Replace NEW_PASSWORD_HERE with the new password you've chosen.

wp user update USERNAME --user_pass="NEW_PASSWORD_HERE"

The WordPress user's password has now been changed.

Resetting Your WordPress Password By Editing functions.php

To set a new WordPress password using an SFTP client, SFTP in to your server and navigate to your active theme's directory.

APPNAME/public/wp-content/themes/ACTIVETHEME

Next, open functions.php and add the following line after the first line in the file (that is, add the following line after the line that says <?php). Replace NEW_PASSWORD with the new password you've chosen.

wp_set_password( 'NEW_PASSWORD', 1 );

If there is more than one WordPress user account, change the number 1 to the ID of the user. If you're unsure of the ID of the WordPress user, you can use the wp command to list users.

Save functions.php back to your server.

You will now be able to log into WordPress with the new password.

After you've verified you can log in with the new password, edit functions.php and remove the new line you'd added.

Last updated: July 25, 2023

Launch your first site in 5 minutes