将用户从一个数据库导入到另一个数据库并保存密码

时间:2017-12-28 作者:M.Mccrea

我一直在尝试制定一种方法,从一个数据库中获取用户的数据库SQL文件,并将其添加到另一个WordPress数据库中,同时将旧的WordPress站点密码保存到新的WordPress安装中。我知道盐必须是一样的才能起作用,而且我知道wp_usermetawp_user 是我需要导入的表。

我只想知道如果这样做了,人们还需要更改密码吗?

1 个回复
SO网友:bueltge

首先,我认为应该通过linux同步数据库表rsync 命令这是一种可靠的方法,更像是wp安装及其依赖项中的脚本。

但是,在更改密码后,您将更新第二个表中的密码。我认为你应该在更改后使用WP钩子,并在这个钩子上激活密码的副本。钩子是

/**
  * 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 );
但是,您也可以在更改配置文件(包括更改密码挂钩)后使用挂钩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 );

结束

相关推荐

Database Name Change

我读到,使用wp\\uu之外的其他东西作为数据库前缀更安全,所以我下载了我的数据库前缀wp\\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu