Thank you for very useful module.

When I create a new user and select to send them a welcome e-mail, is it possible to include their Alternate Login in the body of the e-mail?

In other words, is there a variable that I can use to display this field like !username ?

Best Regards,

Comments

joemako’s picture

My current work-around is to set their password the same as their Alternate Login and just use !password in the Welcome e-mail body.

So this works for me, but if there is a way to get to the variable, that would be nice.

hunmonk’s picture

this could probably be implemented by leveraging hook_mail_alter() and hook_form_alter(). i have no interest in writing this patch, but if somebody sponsors me to write it, or submits a patch for it, i'll be happy to review and commit if it's quality work.

adaven’s picture

StatusFileSize
new1.38 KB

Here's a quick module I put together that implements this feature. It's for D6, but should be easy to backport to D5. Thanks go to hhanna for the idea.

hunmonk’s picture

Version: 5.x-1.8 » 7.x-1.x-dev

will consider integrating the mini-module in #3 into alt_login for the 7.x branch.

fj3’s picture

I use to ver.6.10.

>>alt_login_mail.zip

This mini-module can will use in 6.10?

hunmonk’s picture

see http://drupal.org/project/alt_login#commitment for how feature requests are handled

Taxoman’s picture

Has this been considered for inclusion in the 7.x branch yet?

cjsmith87’s picture

Hi, I need this for my drupal 7 site, cant seem to find a way to get the alternate login field into the welcome email. I have tried porting the code above to drupal but I get an error:

Notice: Undefined index: admin_created in matrixcom_form_user_admin_settings_alter() (line 79 of ...

Im assuming this is because it works differently in drupal 7. Can anyone help here? Making Alt Login a token would also be useful so I can add it the same as my profile fields.

cjsmith87’s picture

Ok solved it, for anyone who is looking for this, the following code can be placed in a custom module and creates a token for the Alt_Login field so it can be used as a token in the welcome emails:


/**
 * Implements hook_token_info().
 */
function MYMODULENAME_token_info() {
  $types['custom'] = array(
    'name' => t("Custom Tokens"),
    'description' => t("Custom Tokens"),
  );
  
  // custom specific tokens.
  $custom['alt_login'] = array(
    'name' => t("Alternate Login"),
    'description' => t("The alternate login id field"),
  );
 
  return array(
    'types' => $types,
    'tokens' => array(
      'custom' => $custom,
    ),
  );
}

/**
 * Implements hook_tokens().
 */
function MYMODULENAME_tokens($type, $tokens, array $data = array(), array $options = array()) {
  global $user;
  
  $replacements = array();
  
  if ($type == 'custom') {
   $account = $data['user'];
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'alt_login':
          $replacements[$original] = !empty($account->alt_login) ? $account->alt_login : t('N/A');
        break;
       }
    }
  }
  
  return $replacements;
}

And Dont forget to flush the cache so that the token shows up! You can then add it to the welcome emails!

csevb10’s picture

Issue summary: View changes
StatusFileSize
new1.3 KB

This can be done a variety of ways, but I liked the token based approach as well. Since this issue exists, I'll post my code in case anyone wants to use it. I basically created it with the assumption that this is something alt_login would (or could) provide so it's here as a patch.
Hope it helps. :-)
--Bill