WordPress 6.8, released in April 2025, changed how every site stores user passwords, and this article helps the admins who run those sites deal with the side effects. WordPress keeps a hash of each password, a scrambled one-way copy, in the user_pass column of the wp_users table. Since 6.8 that hash is made with bcrypt, the password hashing built into PHP, instead of phpass, an older library. A normal upgrade breaks nothing, because 6.8 still accepts the old hashes and converts each one at that user’s next login. Problems show up later, after a downgrade, an old restore or a user export, and the steps below fix each of those cases.
What you’ll accomplish
- Count how many users on a site still have the old phpass hash and how many have moved to bcrypt.
- Find out whether a plugin replaces the WordPress hashing functions on your site.
- Get people logged in again after a site was rolled back below 6.8 or old core files were restored over a newer database.
- Export users to another system, or import them from one, without forcing a password reset on everyone.
- Change the hashing cost or algorithm with the two filters added in 6.8, if you have a reason to.
Prerequisites
You need SSH access to the account that hosts the site and WP-CLI, the WordPress command-line tool. On cPanel, the account’s Terminal page works too. If WP-CLI is missing, the WP-CLI install guide for cPanel sets it up without root. Every database step also works in phpMyAdmin if you only have the cPanel interface.
The examples use the default table prefix wp_. Run wp db prefix to see yours, and change the table names in the SQL if it differs.
Take a database backup before you change any password: wp db export writes one to the current folder.
How it works
Since 6.8, wp_hash_password() hashes a new password with PHP’s password_hash() and the bcrypt algorithm. Before hashing, WordPress runs the password through HMAC-SHA384, a keyed hash, and base64-encodes the result. The reason is a bcrypt limit: it only reads the first 72 bytes of its input, so a long passphrase would otherwise lose its tail. WordPress then puts $wp in front of the standard bcrypt string. A stored hash therefore starts with $wp$2y$, followed by the bcrypt cost, a number that sets how much work each check takes.
Old hashes start with $P$, the phpass format WordPress used for years. When someone logs in, wp_check_password() reads the prefix of the stored hash and picks the matching check.
The middle path is the gradual migration. After a successful login with a username or email address and password, WordPress calls wp_password_needs_rehash(). If the stored hash is not a current $wp bcrypt hash, WordPress saves a new one. Users who never log in keep their $P$ hash indefinitely, and that is fine: it still works.
The check also handles two other cases. A hash of 32 characters or fewer is treated as an MD5 hash, the very old format, and still accepted. A hash with no $wp prefix and no $P$ prefix, such as a plain $2y$ bcrypt hash from another application, goes to PHP’s password_verify(). Both are rewritten to the $wp format at the next login.
The right-hand path is the failure. WordPress 6.7 and older send every hash longer than 32 characters to phpass, and phpass has no idea what the $wp prefix means. A correct password is then rejected with the usual “password you entered is incorrect” message.
Application passwords, password reset keys and personal-data request keys changed too. These values are random and long, so they do not need a slow hash. Since 6.8 they use wp_fast_hash(), which runs BLAKE2b, a fast general-purpose hash, through PHP’s sodium functions and stores the result with a $generic$ prefix. Older hashes of these values still verify. Like the user passwords, values hashed this way are unreadable to WordPress 6.7 and older.
Step-by-step
1. Confirm the WordPress version. The behaviour above applies from 6.8 onward.
wp core version
Example output:
6.8.1
Any version from 6.8 up writes $wp hashes. If you see 6.7 or lower, the site cannot read hashes that a newer copy of the site wrote, which is the situation in steps 5 and 6.
2. Count the hash formats in wp_users. The quoted heredoc (<<'SQL') sends the query to WP-CLI on standard input. The quotes also stop the shell from touching dollar signs, which matters for the queries further down.
wp db query <<'SQL'
SELECT LEFT(user_pass, 3) AS prefix, COUNT(*) AS users
FROM wp_users
GROUP BY prefix;
SQL
Example output:
prefix users
$P$ 412
$wp 57
$wp rows are bcrypt hashes written by 6.8 or later. $P$ rows are phpass hashes from before the upgrade, or from users who have not logged in since. A row like $2y means something wrote vanilla bcrypt without the WordPress prefix, usually a plugin or an import. Three hex characters, such as 5f4, point to an old MD5 hash.
3. List who still has an old hash. This helps you judge the impact of a rollback before you make one.
wp db query <<'SQL'
SELECT ID, user_login, user_registered
FROM wp_users
WHERE user_pass LIKE '$P$%'
ORDER BY ID;
SQL
Example output:
ID user_login user_registered
1 siteadmin 2019-03-11 16:20:47
14 mlavoie 2021-08-02 09:05:13
4. Check whether a plugin replaces the hashing. wp_hash_password() and wp_check_password() are pluggable functions, meaning a plugin can define its own version and WordPress then skips the core one. Ask PHP where the active version lives.
wp eval 'echo (new ReflectionFunction("wp_hash_password"))->getFileName(), PHP_EOL;'
Example output:
/home/shopco/public_html/wp-includes/pluggable.php
A path under wp-includes/pluggable.php means core handles hashing. A path under wp-content/plugins/ or wp-content/mu-plugins/ means a plugin does, and the formats above may not apply. Then check the two other override points:
wp eval 'var_dump( ! empty( $GLOBALS["wp_hasher"] ), has_filter( "wp_hash_password_algorithm" ) );'
Example output:
bool(false)
bool(false)
If the first value is true, some code has set the global $wp_hasher object. WordPress then uses that object for every hash and never converts to bcrypt. If the second is not false, a filter changes the algorithm, which step 7 explains.
5. Recover logins after a rollback below 6.8. This is the common emergency. A site was rolled back to 6.7, or a files-only backup put old core files over a database that 6.8 had already used. Every user who logged in under 6.8 now has a $wp hash the old core cannot check.
The cleanest fix is to put WordPress back on 6.8 or later, because every hash then works again:
wp core update
WP-CLI prints a few progress lines while it downloads and unpacks the release. The last line should read:
Success: WordPress updated successfully.
Run wp core version again and confirm it shows 6.8 or higher. Nobody needs a new password, and application passwords created under 6.8 work again too.
6. If you must stay below 6.8 for now, reset only the affected accounts. Start by listing them, so you know exactly whom to contact:
wp db query <<'SQL'
SELECT ID, user_login, user_email
FROM wp_users
WHERE user_pass LIKE '$wp%'
ORDER BY ID;
SQL
Example output:
ID user_login user_email
22 jtremblay jtremblay@example.com
57 ops-bot ops@example.com
Each row is a user who cannot log in on this core. Users missing from the list are unaffected. Set a new password for one account with the --prompt option, which makes WP-CLI ask for the value so it stays out of your shell history:
wp user update jtremblay --prompt=user_pass
Example output:
Success: Updated user 22.
The old core writes a $P$ hash, which every version can read. WordPress also emails that user to say the password changed; add --skip-email if you would rather tell them yourself. The other users on the list can use the “Lost your password?” link on the login page, as long as the site can send email. A reset done on the old core writes a $P$ hash too. Application passwords created under 6.8 stay unusable on the old core, so recreate them from each user’s profile.
Without SSH, the old MD5 method still works on both old and new cores. In phpMyAdmin, open wp_users, edit the user’s row, choose the MD5 function for user_pass, enter a temporary password and save. Log in with it and change it right away from the profile screen. WordPress replaces the MD5 hash with a stronger one at that first login.
7. Change the cost or algorithm only with a reason. WordPress 6.8 added two filters. wp_hash_password_algorithm picks the PHP algorithm constant, bcrypt by default. wp_hash_password_options passes options such as the bcrypt cost. A higher cost slows down attackers who steal the database, and it also slows every login on a busy server. For example, this must-use plugin, a PHP file in wp-content/mu-plugins/ that WordPress always loads, sets the bcrypt cost to 12:
<?php
// Raise the bcrypt cost for new and rehashed WordPress passwords.
add_filter( 'wp_hash_password_options', function ( $options, $algorithm ) {
if ( PASSWORD_BCRYPT === $algorithm ) {
$options['cost'] = 12;
}
return $options;
}, 10, 2 );
Save it as wp-content/mu-plugins/bcrypt-cost.php, log in once as siteadmin (or put your own login in the query), then look at that hash. The cost is the two digits after $2y$:
wp db query <<'SQL'
SELECT user_login, LEFT(user_pass, 10) AS starts_with
FROM wp_users
WHERE user_login = 'siteadmin';
SQL
Example output:
user_login starts_with
siteadmin $wp$2y$12$
Existing hashes move to the new cost at each user’s next login, because wp_password_needs_rehash() compares them with the current settings. PHP 8.4 raised its own default bcrypt cost from 10 to 12, so a PHP upgrade alone triggers the same quiet rehashing. If you switch the algorithm to Argon2, check password_algos() on the server first. WordPress stores Argon2 hashes without the $wp prefix and skips the pre-hash step.
8. Export or import users the right way. Another system that receives a $wp$2y$ hash has to repeat both WordPress steps before it can verify a password. It must strip the leading $wp, then compare against the HMAC-SHA384 of the password, base64-encoded. In PHP, the check is two lines:
<?php
// Verify a WordPress 6.8+ hash outside WordPress.
$prehashed = base64_encode( hash_hmac( 'sha384', $password, 'wp-sha384', true ) );
$is_valid = password_verify( $prehashed, substr( $stored_hash, 3 ) );
$is_valid is true only when $password is the right password for that hash. Test it with one known account before you trust it with the rest.
Going the other way is easier. A standard bcrypt hash from another PHP application, starting with $2y$, can go straight into user_pass. WordPress 6.8 verifies it with password_verify() and converts it at the first login. For anything else, such as SSO plugins or custom code that reads user_pass, call wp_check_password() instead of reimplementing the format. It handles every prefix above and keeps working if WordPress changes the format again.
Validate it works
Log in as a user from the $P$ group in step 3, then rerun the count from step 2. That user should have moved to $wp:
wp db query <<'SQL'
SELECT user_login, LEFT(user_pass, 7) AS starts_with
FROM wp_users
WHERE user_login = 'siteadmin';
SQL
Example output:
user_login starts_with
siteadmin $wp$2y$
After step 5, test one account from each group in step 2. After step 6, test one account you reset. Use a private browser window so an existing session cookie does not hide a failure. For application passwords, send one authenticated REST request as shown in the application passwords guide and expect HTTP 200.
Troubleshooting
- Users log in but their hash stays
$P$. The rehash only runs inside the username and email password checks. Logins through SSO, social login or two-factor plugins that replace those checks may never trigger it. A$wp_hasherobject or a filter onpassword_needs_rehashalso stops it, so rerun step 4. - Hashes start with
$2y$and have no$wp. A plugin defines its ownwp_hash_password(), often one written before 6.8 to add bcrypt. Core 6.8 still verifies those hashes if you remove the plugin, and converts them at the next login. - Every user who logged in recently is locked out. That is the rollback case: the core is older than 6.8 while the database holds
$wphashes. Runwp core versionand go to step 5. - A password reset link says the key is invalid right after a restore. Reset keys are stored with the time and a hash in
user_activation_key. A link sent before the restore points to a key the restored database never saw. A key written by 6.8 also cannot be checked by 6.7 or older. Request a new link from the current site. - An external app or custom script rejects correct passwords for new users only. It verifies
user_passwith phpass orcrypt(), and neither understands the$wpprefix. Switch it towp_check_password(), or apply the two-step check from step 8.
When this is the wrong approach
Do not reset every password to “finish” the migration. Mixed $P$ and $wp hashes are the expected state for a long time, and both work on 6.8 or later. Forcing resets costs users time and support tickets for no security gain on accounts that log in normally.
Treat step 6 as a stopgap. The real fix for a site stuck below 6.8 is to upgrade it, and an old core misses security fixes that matter more than the hash format. Avoid copying the 6.8 password check into an old core with a custom plugin. That code replaces a login function and is easy to get subtly wrong, while the upgrade fixes the same problem with nothing to maintain.
If the site’s users sign in only through an external identity provider, the WordPress hash barely matters, so audit the SSO plugin’s own session and role handling instead. For the full behaviour of the core functions, see the WordPress reference for wp_hash_password() and wp_check_password().
Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.