function drush_user_login

8.0.x user.drush.inc drush_user_login($inputs = '', $path = NULL)
6.x user.drush.inc drush_user_login($user = NULL, $path = NULL)
7.x user.drush.inc drush_user_login($inputs = '', $path = NULL)
4.x user.drush.inc drush_user_login($name = NULL)
5.x user.drush.inc drush_user_login($user = NULL, $path = NULL)
master user.drush.inc drush_user_login($inputs = '', $path = NULL)

Displays a one time login link for the given user.

1 string reference to 'drush_user_login'
user_drush_command in commands/user/user.drush.inc
Implementation of hook_drush_command().

File

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

Code

function drush_user_login($user = NULL, $path = NULL) {
  $user_object = $uid = FALSE;
  $args = func_get_args();
  if (drush_get_option('uid', FALSE) || drush_get_option('name', FALSE) || drush_get_option('mail', FALSE)) {
    // One of the user options was passed, so we prefer that to the user
    // argument.
    $user = NULL;
    // If we only have a single argument and one of the user options is passed,
    // then we assume the argument is the path to open.
    if (count($args) == ) {
      $path = $args[];
    }
  }
  else if (empty($user)) {
    // No user option or argument was passed, so we default to uid 1.
    $uid = ;
  }
  // Try and load a user from provided options and arguments.
  if ($uid || $uid = reset(_drush_user_get_users_from_options_and_arguments($user))) {
    $user_object = user_load($uid);
  }

  if ($user_object !== FALSE && $user_object->status) {
    $options = array();
    if ($path) {
      $options['query']['destination'] = $path;
    }
    $link = url(user_pass_reset_url($user_object) . '/login', $options);
    drush_start_browser($link);
    drush_print($link);
    return $link;
  }
  else {
    drush_set_error("The user account could not be loaded or is blocked!");
  }
}