I have been trying to formulate a way to take a database SQL file of users from one database and add it to another WordPress database while saving the old WordPress site passwords on the new WordPress install. I know that the salts need to be the same for it to work, and I know that the wp_usermeta and wp_user are the tables i need to import.

I just need to know if it do this will people still need to change their passwords?

  • I can do a migration and it keeps all the users and pass, there must be a way. Does the site you are migrating too need to stay in-tact and you are just adding the users? – Patrick Dec 28 '17 at 7:41
  • yes, it should remain the same and i just need to add the users. – M.Mccrea Dec 28 '17 at 14:55
  • Does anyone else have a suggestion? – M.Mccrea Jan 2 at 18:08

At first, I think you should sync your database tables via linux rsync command. It is a solid way, more as an script inside your wp install and his dependencies.

However you will update the password in the second table after an change of a password. I think you should use the WP hook after the change and fire on this hook an copy of the password. The hook is

/**
  * Fires after the user's password is reset.
  *
  * @since 4.4.0
  *
  * @param object $user     The user.
  * @param string $new_pass New user password.
  */
  do_action( 'after_password_reset', $user, $new_pass );

However you can also use the hook after a change of the profile, that include the change of the password - Hook profile_update.

/**
 * Fires immediately after an existing user is updated.
 *
 * @since 2.0.0
 *
 * @param int     $user_id       User ID.
 * @param WP_User $old_user_data Object containing user's data prior to update.
 */
do_action( 'profile_update', $user_id, $old_user_data );

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.