I think it would be great to have token support for this module (if possible). I send out emails to users via Views Bulk Operations/Views Send and think it would be very handy to include a [login-one-time] token that would generate the link. Any chance this could be supported?

Comments

danielb’s picture

I've never done this before, so let me just think out loud here...

<?php
/**
 * Implementation of hook_token_values().
 */
function login_one_time_token_values($type, $object = NULL) {
  if ($type == 'user') {
    $tokens['login-one-time'] = login_one_time_get_link($object);
    return $tokens;
  }
}

/**
 * Implementation of hook_token_list().
 */
function login_one_time_token_list($type = 'all') {
  if ($type == 'user' || $type == 'all') {
    $tokens['login-one-time'] = t('Login one time link (Default path)');
    return $tokens;
  }
}
?>

Would that be sufficient?

I think I'll have to fix #852800: Compatibility with realname module first in case it changes things too much.

danielb’s picture

Status: Active » Fixed

I've added that. There is more that could be done like adding tokens to go to a specific page, etc... but I don't want to go nuts with it at this stage.

jeff.k’s picture

Thanks! I will be testing it later this week.

jeff.k’s picture

When enabled it seems to throw an error

warning: Invalid argument supplied for foreach() in ....\sites\all\modules\token\token.module on line 385.

In looking at http://drupal.org/handbook/modules/token your code needs to be slightly altered

$tokens['login-one-time'] = t('Login one time link (Default path)');

should be

$tokens['user']['login-one-time'] = t('Login one time link (Default path)');

danielb’s picture

Status: Fixed » Active

oh ok, woops

danielb’s picture

Status: Active » Fixed

OK updated.

jeff.k’s picture

Thanks for the quick turnaround!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.