You are here

function _pmperson_migrate_create_user in Drupal PM (Project Management) 8

Same name and namespace in other branches
  1. 7.3 pmperson/includes/pmperson.migrate.inc \_pmperson_migrate_create_user()
  2. 7.2 pmperson/includes/pmperson.migrate.inc \_pmperson_migrate_create_user()

Create a Drupal User.

1 call to _pmperson_migrate_create_user()
pmperson_migrate_create_users_if_required in pmperson/includes/pmperson.migrate.inc
Creates Drupal User and associate it with pmperson node.

File

pmperson/includes/pmperson.migrate.inc, line 447
Migration functions for the PM Person module.

Code

function _pmperson_migrate_create_user($record) {
  $account = FALSE;
  $node = node_load($record->nid);
  if ($node) {
    $mail = $record->email;
    if (empty($mail) or user_load_by_mail($record->email)) {
      $mail = 'pmperson_' . $node->nid . '@example.com';
    }
    $name = check_plain($node->title);
    $name = _pmperson_migrate_generate_unique_username($name, TRUE, array(
      $mail,
    ));
    $account = user_save(NULL, array(
      'name' => $name,
      'mail' => $mail,
      'init' => $mail,
      'pass' => user_password(),
    ));
  }
  return $account;
}