Page 1 of 1

Substitution tag error

Posted: Sun Jan 22, 2023 6:54 am
by lww
Script URL: https://help.covenantepc.org/
Version of script: 3.4.2
Hosting company: Digital Ocean
URL of phpinfo.php: https://help.covenantepc.org/phpinfo.php
URL of session_test.php: https://help.covenantepc.org/session_test.php
What terms did you try when SEARCHING for a solution: substitution tag template

Write your message below:
The %%FIRST_NAME%% tag is not being substituted correctly in the reset_password.txt email templates. The %%NAME%% tag works correctly, but %%FIRST_NAME%% is passed through into the email without being substituted. This happens for both the text & html templates. Here's a snippet from the email as sent:

Code: Select all

Content-Transfer-Encoding: quoted-printable

%%FIRST_NAME%%,

We were told that you forgot your help desk password. It happens to every=
one!
The mfa_verification.txt templates have a similar problem. In this case the %%FIRST_NAME%% tag is not substituted (same as above), but the %%NAME%% tag is substituted with just the first name.

Also, the editing pages for these 2 templates show all of the ticket specific substutution tags as available. On most of the other template pages only the relevant tags are shown.

Thanks,

--Bill

Re: Substitution tag error

Posted: Sun Jan 22, 2023 6:57 pm
by lww
OK, I think I see why this is happening. The editing page for the reset_password.txt templates shows all of the tags as available to be inserted, but only a few of those tags are actually processed by admin/password.php and %%FIRST_NAME%% isn't one of them. I'll just revert back to using %%NAME%%, which does get processed by admin/password.php.

I haven't had time to dig into what's happening with mfa_verification.txt yet...

Thanks,

--Bill

Re: Substitution tag error

Posted: Mon Jan 23, 2023 1:38 am
by lww
The situation is similar for mfa_verification.txt. While editing the templates, all of the tags are available for insertion, but only 4 of them are actually processed by send_mfa_email() in mfa_functions.inc.php. Like reset_password.txt, %%NAME%% gets processed but %%FIRST_NAME%% does not. The difference this time is that here %%NAME%% is actually being replaced with the first name only, as you can see here:

Code: Select all

// Replace message special tags
list($msg, $html_msg) = hesk_replace_email_tag('%%NAME%%', hesk_full_name_to_first_name(hesk_msgToPlain($name, 1, 1)), $msg, $html_msg);
list($msg, $html_msg) = hesk_replace_email_tag('%%SITE_TITLE%%', hesk_msgToPlain($hesk_settings['site_title'], 1, 0), $msg, $html_msg);
list($msg, $html_msg) = hesk_replace_email_tag('%%SITE_URL%%', $hesk_settings['site_url'] . ' ', $msg, $html_msg);
list($msg, $html_msg) = hesk_replace_email_tag('%%VERIFICATION_CODE%%', $verification_code, $msg, $html_msg);
Thanks,

--Bill

Re: Substitution tag error

Posted: Mon Jan 23, 2023 8:33 am
by Klemen
Hi Bill,

Thanks for the heads-up. The unsupported tags should indeed be removed (or added support for them), and the ones being used should be consistent throughout templates.

I will ensure we look into this more carefully and fix it for the next release.

Re: Substitution tag error

Posted: Thu Jan 26, 2023 3:38 pm
by lww
Thanks, Klemen. I appreciate the followup! Hesk is a great product!

--Bill

Re: Substitution tag error

Posted: Tue Jan 16, 2024 11:49 pm
by cwyenberg
Not sure if this is related but I will add to this by saying that if a first name is 2 characters or less, the %%FIRST_NAME%% tag will substitute the full name. For example, the %%FIRST_NAME%% tag will render Ed Smith as Ed Smith but Edd Smith will render as Edd.

I'm thinking there is a simple code edit to correct this but I've had no success locating where the logic is applied.

Re: Substitution tag error

Posted: Wed Jan 17, 2024 7:30 am
by Klemen
Good point.

Changing

Code: Select all

if(hesk_mb_strlen($first_name) < 3)
to

Code: Select all

if(hesk_mb_strlen($first_name) < 2)
in /inc/common.inc.php (edit the file in a powerful editor, such as Notepad++) should fix that.

Re: Substitution tag error

Posted: Wed Jan 17, 2024 3:48 pm
by cwyenberg
Thank you. Works perfectly.