Importing users from one database to another and saving passwords

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 );

Leave a Comment