function _drush_user_print_info

6.x user.drush.inc _drush_user_print_info($uid)
4.x user.drush.inc _drush_user_print_info($uid)
5.x user.drush.inc _drush_user_print_info($uid)

Print information about a given uid

3 calls to _drush_user_print_info()
drush_user_cancel in commands/user/user.drush.inc
Cancels a user account.
drush_user_create in commands/user/user.drush.inc
Creates a new user account.
drush_user_information in commands/user/user.drush.inc
Prints information about the specified user(s).

File

commands/user/user.drush.inc, line 395
Drush User Management commands

Code

function _drush_user_print_info($uid) {
  if (drush_drupal_major_version() >= 7) {
    $userinfo = user_load($uid);
  }
  else {
    $userinfo = user_load(array('uid' => $uid));
  }
  if (drush_get_option('full')) {
    $userinfo = (array) $userinfo;
    $userinfo_pipe = array();
    unset($userinfo['data']);
    unset($userinfo['block']);
    unset($userinfo['form_build_id']);
    foreach ($userinfo as $key => $val) {
      if (is_array($val)) {
        drush_print($key . ': ');
        drush_print_r($val);
        $userinfo_pipe[] = '"' . implode(",", $val) . '"';
      }
      else {
        if ($key === 'created' OR $key === 'access' OR $key === 'login') {
          drush_print($key . ': ' . format_date($val));
          $userinfo_pipe[] = $val;
        }
        else {
          drush_print($key . ': ' . $val);
          $userinfo_pipe[] = $val;
        }
      }
    }
    drush_print_pipe(implode(",", $userinfo_pipe));
    drush_print_pipe("\n");
  }
  else {
    $userinfo_short = array(
      'User ID' => $userinfo->uid,
      'User name' => $userinfo->name,
      'User mail' => $userinfo->mail,
    );
    $userinfo_short['User roles'] = implode(', ', $userinfo->roles);
    $userinfo->status ? $userinfo_short['User status'] = 'active' : $userinfo_short['User status'] = 'blocked';
    drush_print_table(drush_key_value_to_array_table($userinfo_short));
    drush_print_pipe("$userinfo->name,$userinfo->uid,$userinfo->mail,$userinfo->status,\"" . implode(',', $userinfo->roles) . "\"\n");
  }
}