Drupal 6 user password import to Drupal 7

后端 未结 3 856
情书的邮戳
情书的邮戳 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-06 09:35

    I don't have enough points to add a comment, but I've made several refinements to hross' answer (and submitted a draft update).

    Here's an improved script with documentation and the ability to specify a non-default users table for those doing manual Drupal 6 to 7 merges. It also incorporates jpb's checking.

     10 ORDER BY uid", 0, $count);
      foreach ($result as $account) {
        $has_rows = TRUE;
        if (substr($account->pass, 0, 1) != 'U') {
          echo "updating account: " . $account->uid . " \r\n";
          $new_hash = user_hash_password($account->pass, $hash_count_log2);
          if ($new_hash) {
            // Indicate an updated password.
            $new_hash  = 'U' . $new_hash;
            db_update($databasename)
              ->fields(array('pass' => $new_hash))
              ->condition('uid', $account->uid)
              ->execute();
          }
        }
      }
      echo "Done.";
    ?>
    

提交回复
热议问题