The function to use when programmatically setting the password is wp_hash_password
. I ran into a problem similar to mediabros – I’d update the user_pass
column in the wp_users
table to a wp_hash_password
hashed string, but login with the new password was still just not working.
The trick was to make a call to wp_cache_delete($ID, 'users')
after setting the password programmatically, clearing the WordPress cache (which apparently stores hashed passwords along with other user details).
Of course, this only applies if you have enabled the WordPress object cache using define('ENABLE_CACHE', true)
in wp-config.php