function drush_drupal_login

6.x drupal.inc drush_drupal_login($drush_user)
3.x drush.php drush_drupal_login($drush_user)
4.x drush.php drush_drupal_login($drush_user)
5.x drupal.inc drush_drupal_login($drush_user)

Log the given user in to a bootstrapped Drupal site.

Parameters

mixed: Numeric user id or user name.

Return value

boolean TRUE if user was logged in, otherwise FALSE.

1 call to drush_drupal_login()
_drush_bootstrap_drupal_login in includes/environment.inc
Log into the bootstrapped Drupal site with a specific username or user id.

File

./drush.php, line 197
drush is a PHP script implementing a command line shell for Drupal.

Code

function drush_drupal_login($drush_user) {
  global $user;
  if (drush_drupal_major_version() >= 7) {
    $user = is_numeric($drush_user) ? user_load($drush_user) : user_load_by_name($drush_user);
  }
  else {
    $user = user_load(is_numeric($drush_user) ? array('uid' => $drush_user) : array('name' => $drush_user));
  }

  if (empty($user)) {
    if (is_numeric($drush_user)) {
      $message = dt('Could not login with user ID #%user.', array('%user' => $drush_user));
    }
    else {
      $message = dt('Could not login with user account `%user\'.', array('%user' => $drush_user));
    }
    return drush_set_error('DRUPAL_USER_LOGIN_FAILED', $message);
  }

  return TRUE;
}