(SMF bug) Admin registering a user, email does not send a link to the forum

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
It's not something I think you'd encounter that often but a user that I look after just reported this to me in SMF and I see no reason why we would have touched this thus far.

If you register a user from the admin panel, it will email them with the username and password but it actually won't email them a link to the forum >_<

And because of how the templates are set up, well, it's a bit more complex. I'm going to document the SMF code fix here because that's what has to be done first, but then we can fix it in Wedge just after since the code should be virtually if not actually identical.


We need to create somewhere we can actually inject the $scripturl into. Themes/default/languages/EmailTemplates.english.php:
Code: [Select]
'admin_register_immediate' => array(
'subject' => 'Welcome to {FORUMNAME}',
'body' => 'Thank you for registering at {FORUMNAME}. Your username is {USERNAME} and your password is {PASSWORD}.

{REGARDS}',
),

Replace with:
Code: [Select]
'admin_register_immediate' => array(
'subject' => 'Welcome to {FORUMNAME}',
'body' => 'Thank you for registering at {FORUMNAME}. Your username is {USERNAME} and your password is {PASSWORD}.

You can reach {FORUMNAME} by visiting {SCRIPTURL} in your browser.

{REGARDS}',
),

The line's a bit crap but I deliberately did not want to leave it as the closing element on the line, for all the fun and games the trailing . would leave.


Other thoughts:
After finding loadEmailTemplate, I discovered that {SCRIPTURL} is a replacement that's already handled natively there, though I have to admit I didn't think it was, and started digging into where the replacements were defined in Subs-Members.php for that email. Though I have to say, loadEmailTemplate is in a funny place and it makes me wonder about doing other things with restructuring internal facilities, perhaps like moving all the email functions into one place and invoking that when needed rather than this other slightly weird hierarchy of things needed. (Subs-Post.php, primarily, for all the email related stuff, even sending PMs)
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Nao

  • Dadman with a boy
  • Posts: 16,082

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
The bug is that if you create a user from the admin panel, you can email them their user name and password - but it won't actually tell them where the forum is.

The fix is documented: replace the first bit of code with the second in the email template.

I didn't apply it last night because I had other stuff going on and forgot to add it into the other commit I did.

Nao

  • Dadman with a boy
  • Posts: 16,082

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278