Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
grasmash CreditAttribution: grasmash commentedMy 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.
Comment #2
danielb CreditAttribution: danielb commentedyeah I think I know what this is, it's because the way tokens are done it works stuff out a 2nd time
Comment #3
grasmash CreditAttribution: grasmash commentedYes. I found the issue, and the fix.
When you call token_replace() in login_one_time_mail(), pass the $path variable:
Then, when you call login_one_time_get_link() in hook_tokens(), pass the data along:
This way, the correct path is generated in the email token.
Comment #4
danielb CreditAttribution: danielb commentedcheers i've committed your suggestions