You are here

function _user_resource_resend_welcome_email in Services 7.3

Send a welcome email for the specified user.

1 string reference to '_user_resource_resend_welcome_email'
_user_resource_definition in resources/user_resource.inc

File

resources/user_resource.inc, line 840

Code

function _user_resource_resend_welcome_email($uid) {
  global $language;
  $account = user_load($uid);
  if (empty($account)) {
    return services_error(t('There is no user with ID @uid.', array(
      '@uid' => $uid,
    )), 404);
  }
  $user_register = variable_get('user_register', 2);
  switch ($user_register) {
    case USER_REGISTER_ADMINISTRATORS_ONLY:
      $op = 'register_admin_created';
      break;
    case USER_REGISTER_VISITORS:
      $op = 'register_no_approval_required';
      break;
    case USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL:
      $op = 'register_pending_approval';
  }

  // Mail the welcome emaiil using current language.
  $mail = _user_mail_notify($op, $account, $language);
  if (!empty($mail)) {
    watchdog('user', 'Welcome message has been re-sent to %name at %email.', array(
      '%name' => $account->name,
      '%email' => $account->mail,
    ));
  }
  else {
    watchdog('user', 'There was an error re-sending welcome message to %name at %email', array(
      '%name' => $account->name,
      '%email' => $account->mail,
    ));
  }

  // Everything went right.
  return TRUE;
}