Substitution tag error

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
lww
Posts: 4
Joined: Sat Jan 21, 2023 6:54 pm

Substitution tag error

Post 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
lww
Posts: 4
Joined: Sat Jan 21, 2023 6:54 pm

Re: Substitution tag error

Post 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
lww
Posts: 4
Joined: Sat Jan 21, 2023 6:54 pm

Re: Substitution tag error

Post 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
Klemen
Site Admin
Posts: 10139
Joined: Fri Feb 11, 2005 4:04 pm

Re: Substitution tag error

Post 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.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
lww
Posts: 4
Joined: Sat Jan 21, 2023 6:54 pm

Re: Substitution tag error

Post by lww »

Thanks, Klemen. I appreciate the followup! Hesk is a great product!

--Bill
cwyenberg
Posts: 56
Joined: Sat Jun 16, 2018 12:53 am

Re: Substitution tag error

Post 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.
Klemen
Site Admin
Posts: 10139
Joined: Fri Feb 11, 2005 4:04 pm

Re: Substitution tag error

Post 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.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
cwyenberg
Posts: 56
Joined: Sat Jun 16, 2018 12:53 am

Re: Substitution tag error

Post by cwyenberg »

Thank you. Works perfectly.
Post Reply