How to migrate users from old drupal d6 site to new drupal 7 site?
Check this article . It describes how to use migrate module and it's API.
Code from this article:

First of all we need to create module by adding folder with name my_migration adding my_migration.info and my_migration.module files. So lets start, code below will have a lot of comments:

//my_migration.info file

name = "User Migrate"
 description = "Migration of data from Drupal 6 to Drupal 7"
 package = "Custom Migrate"
 core = 7.x
 dependencies[] = migrate
 dependencies[] = migrate_extras
 dependencies[] = field
 dependencies[] = file
 dependencies[] = text
 dependencies[] = path
 dependencies[] = taxonomy

 files[] = includes/users.inc

//my_migration.module file
// this file can be empty but we will define some constants
&lt;!--?php /*
 * Define some constants to use in class
 */
define("SOURCE_DATABASE", 'd6_latest'); // Put drupal 6 db name you should also add settings to settings.php
define("CONNECT_NAME", 'migrate');// name of connection to drupal 6 db in settings.php
define('SOURCE_TERM_GARDEN_CAT', 3); // When we will migrate terms we will use it.
define('SOURCE_URL', 'http://path_to_drupal6.site');
define('MIGRATE67_SITE_DIRECTORY', 'public://');


//my_migrate_migrate.inc you should name this file as module_name_migrate.inc 
// if not your migration won't be autoloaded.
&lt;?php

/**
 * Implements hook_migrate_api().
 */
function my_migrate_migrate_api() {
  $api = array(
    'api' =?--&gt; 2,
    'migrations' =&gt; array(
      'MfUserMigrate' =&gt; array('class_name' =&gt; 'MfUserMigrate'),
    ),
  );

  return $api;
}



//my_migration/users.inc

&lt;!--?php /**
 * User migration class to migrate users.
 */
class UserMigrate extends Migration {
  public function __construct() {
    parent::__construct(MigrateGroup::getInstance('UserMigrate'));
    // Select fields from the Drupal 6 user table.
    $query = Database::getConnection('default', CONNECT_NAME)
      -?--&gt;select('users', 'u')
      -&gt;fields('u', array('uid', 'name', 'pass', 'mail', 'created', 'access',
        'login', 'status', 'picture', 'init'));
    // This is supposed to get roles not sure how.
    $source_fields = array(
      'uid' =&gt; t('User ID'),
      'roles' =&gt; t('The set of roles assigned to a user.'),
    );
    // Set source and destination.
    $this-&gt;source = new MigrateSourceSQL($query, $source_fields);
    $this-&gt;destination = new MigrateDestinationUser(array('md5_passwords' =&gt; TRUE));
    // Set up database maping.
    $this-&gt;map = new MigrateSQLMap($this-&gt;machineName,
      array(
        'uid' =&gt; array(
          'type' =&gt; 'int',
          'unsigned' =&gt; TRUE,
          'not null' =&gt; TRUE,
          'description' =&gt; 'D6 Unique User ID',
          'alias' =&gt; 'u',
        )
      ),
      MigrateDestinationUser::getKeySchema()
    );
    // Add simple field mappings
    $this-&gt;addFieldMapping('is_new')
      -&gt;defaultValue(TRUE);
    $this-&gt;addFieldMapping('uid', 'id_to_preserve');
    $this-&gt;addFieldMapping('name', 'name')-&gt;dedupe('users', 'name');
    $this-&gt;addFieldMapping('pass', 'pass');
    $this-&gt;addFieldMapping('mail', 'mail')-&gt;dedupe('users', 'mail');
    $this-&gt;addFieldMapping('language')-&gt;defaultValue('');
    $this-&gt;addFieldMapping('theme')-&gt;defaultValue('');
    $this-&gt;addFieldMapping('signature')-&gt;defaultValue('');
    $this-&gt;addFieldMapping('signature_format')-&gt;defaultValue('filtered_html');
    $this-&gt;addFieldMapping('created', 'created');
    $this-&gt;addFieldMapping('access', 'access');
    $this-&gt;addFieldMapping('login', 'login');
    $this-&gt;addFieldMapping('status', 'status');
    $this-&gt;addFieldMapping('picture')-&gt;defaultValue(0);
    $this-&gt;addFieldMapping('init', 'init');
    $this-&gt;addFieldMapping('timezone')-&gt;defaultValue(NULL);
    $this-&gt;addFieldMapping('roles', 'roles');
  }
  // Set up Roles.
  // massage the user roles before saving
  public function prepareRow($current_row) {
    $source_id = $current_row-&gt;uid;
    $query = Database::getConnection('default', CONNECT_NAME)
      -&gt;select('users_roles', 'r')
      -&gt;fields('r', array('uid', 'rid'))
      -&gt;havingCondition('r.uid', $source_id, '=');
    $results = $query-&gt;execute();
    // add the anonymous role for everyone
    $roles = array('1' =&gt; '1');
    foreach ($results as $row) {
      // adjust the old to new role id's
      // Editors (rid 7) need role id 4
      if ($row-&gt;rid == 7) {
        $roles['4'] = '4';
      }
      elseif ($row-&gt;rid == 4) {
        // producer from 4 to 5
        $roles['5'] = '5';
      }
      elseif ($row-&gt;rid == 5) {
        // blogger from 5 to 6
        $roles['6'] = '6';
      }
      elseif ($row-&gt;rid == 8) {
        // freelancer 8 to 7
        $roles['7'] = '7';
      }
      else {
        // Collaboraters are role id 5 in both old and new dbs
        $roles[$row-&gt;rid] = $row-&gt;rid;
      }
    }
    $current_row-&gt;roles = $roles;
    return TRUE;
  }
} // close the ourUserMigration class