You are here

function user_registrationpassword_mail_alter in User registration password 7

Implements hook_mail_alter().

File

./user_registrationpassword.module, line 477
Enables password creation on registration form.

Code

function user_registrationpassword_mail_alter(&$message) {
  if ($message['module'] == 'user_registrationpassword') {

    // Test if i18n_variable is available.
    if (function_exists('i18n_variable_get')) {
      $language = isset($message['language']) ? $message['language'] : language_default();
      $variables = array(
        'user' => $message['params']['account'],
      );
      $key = $message['key'];
      $components = array(
        'subject',
        'body',
      );
      foreach ($components as $component) {
        $text = i18n_variable_get('user_registrationpassword_' . $key . '_' . $component, $language->language, FALSE);
        if ($text) {
          $text = token_replace($text, $variables, array(
            'language' => $language,
            'callback' => 'user_registrationpassword_mail_tokens',
            'sanitize' => FALSE,
          ));
          switch ($component) {
            case 'subject':
              $message[$component] = $text;
              break;
            case 'body':
              $message[$component] = array(
                $text,
              );
              break;
          }
        }
      }
    }
  }
}