Migration from drupal 6 to 7 keeping user password same

Migration from drupal 6 to 7 keeping user password same

After users' migration from Drupal 6 to Drupal 7, this fast hack enables users to login using their existing passwords. 
You can use the code listed below. 


To avoid changing core files, it would be preferable to construct a custom module and use this function from within that module.

In user.module file .. 
function user_authenticate($name, $password) {
  $uid = FALSE;
  if (!empty($name) && !empty($password)) {
    $account = user_load_by_name($name);
    if ($account) {
      // Allow alternate password hashing schemes.
      require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
      if (user_check_password($password, $account)) {
        // Successful authentication.
        $uid = $account->uid;

        // Update user to new password scheme if needed.
        if (user_needs_new_hash($account)) {
          user_save($account, array('pass' => $password));
        }
      }
      // -----Add this Code After Migration from Drupal 6 to Drupal 7 to allow users to login with same password
      else if($account->pass == md5($password)){ //Check For Drupal 6
          // Successful authentication.
        $uid = $account->uid;

        // Update user to new password scheme.
          user_save($account, array('pass' => $password));
      }
      // -----Add this Code After Migration from Drupal 6 to Drupal 7 to allow users to login with same password
    }
  }
  return $uid;
}

You can also use the following Sandbox project module will give access to users using the old password.
https://www.drupal.org/project/password_6_7
Do submit reviews.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
  • Lazy-loading is enabled for both <img> and <iframe> tags. If you want certain elements skip lazy-loading, add no-b-lazy class name.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.