Drupal 6 user password import to Drupal 7

后端 未结 3 862
情书的邮戳
情书的邮戳 2021-02-06 09:30

I don\'t really need to import any data into my D7 build other than users. I have (by SQL) imported my user data however, the D7 password encryption method is now different.

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-06 09:56

    I think you can create a page named something like rehash.php (in your root, same place as update.php). Then, log in as administrator first, browse to this page second. See code below (most taken from user_update_7200 in the latest drupal 7 install)...

    Worse case, you could create a simple custom module and put this code in there.

    Please note that you should back things up first:

     1 ORDER BY uid", 0, $count);
        foreach ($result as $account) {
          $has_rows = TRUE;
          $new_hash = user_hash_password($account->pass, $hash_count_log2);
          if ($new_hash) {
            // Indicate an updated password.
            $new_hash  = 'U' . $new_hash;
            db_update('users')
              ->fields(array('pass' => $new_hash))
              ->condition('uid', $account->uid)
              ->execute();
          }
        }
    ?>
    

提交回复
热议问题