How do you import members from another system to WordPress and update passwords so they’ll work?

You couldn’t have a more perfect solution, since this is precisely what WordPress core itself has to handle.

See, in early years WP used just one pass MD5 for passwords. Then they went to better hashing, but obviously it should have kept working with old hashes.

Now if you take a look at wp_check_password(), what it is doing (at the moment user attempts to log in) is following:

  1. Checks if hash looks “old”
  2. If so verifies it in “old” mode
  3. If so updates hash to “new” one (using password, which is available at this moment in runtime)
  4. Otherwise verifies in “new” mode

You should simply follow precise same logic! Hook into check_password or override wp_check_password() altogether (it’s so called pluggable function). Then implement same check & upgrade logic for your hashes.

Leave a Comment