Each time that I select to send an email to a user via the admin/people page, the module seems to call login_one_time_get_link() twice.

The first time that it is called, the correct $path is used. The second time, $path is empty, and therefore falls back to the default setting. When the email is sent, it is incorrectly sent with the default path.

Comments

grasmash’s picture

My initial analysis was incorrect. The issue is not that login_one_time_get_link() is being called twice-- that doesn't cause problems. Also, it doesn't always default-- it simply goes to the wrong path according to some other pattern that I haven't recognized yet. Still looking.

danielb’s picture

yeah I think I know what this is, it's because the way tokens are done it works stuff out a 2nd time

grasmash’s picture

Yes. I found the issue, and the fix.

When you call token_replace() in login_one_time_mail(), pass the $path variable:

$body = token_replace($body, array('user' => $params['account'], 'path' => $path));

Then, when you call login_one_time_get_link() in hook_tokens(), pass the data along:

$replacements[$original] = login_one_time_get_link($account, $data['path']);

This way, the correct path is generated in the email token.

danielb’s picture

Status: Active » Fixed

cheers i've committed your suggestions

Status: Fixed » Closed (fixed)

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