Jump to content

EmailPreSend - Mergefields?


Kian

Recommended Posts

wtf.thumb.png.46a3aa7d2283a06244b6fcd6323857ed.png

 

I don't know if it's me or this hook doesn't work as it should. I would expect that $vars['mergefields'] contains an array of all variable declared in the email (eg. {$whmcs_link}, {$signature}, {$firstname}) but this parameter is always empty. When I print $vars this is what I get:

{"messagename":"Password Reset Validation","relid":1}
{"messagename":"Invoice Created","relid":1595}
{"messagename":"Invoice Modified","relid":1595}
{"messagename":"First Invoice Overdue Notice","relid":1595}
{"messagename":"Credit Card Invoice Created","relid":1595}

It happens with any email template so my question is: where the heck are mergefields? There are all parameters (messagename, relid) except mergefields.

Edited by Kian
Link to comment
Share on other sites

16 minutes ago, Kian said:

I don't know if it's me or this hook doesn't work as it should. I would expect that $vars['mergefield']

tell me that's a typo and you have actually used $vars['mergefields'] instead  ?

<?php
function email_hook($vars) {
	$merge_fields = $vars['mergefields'];
	return array("brian" => $merge_fields);
}
add_hook("EmailPreSend",1,"email_hook");

w1ZqUpL.png

Link to comment
Share on other sites

Got it! 😩

EmailPreSend hook point returns mergefields parameter starting from an unknown version of WHMCS. The most recent snapshot of documentation doesn't show "mergefields" section and it is dated 23 Aug 2018. I read all patch notes from v7.0 of 22 Jul 2016 but there's nothing about changes to EmailPreSend.

I'm developing a feature where I need to use mergefields. Of course there's a workaround but this time I don't give a damn about backward compatibility since nobody cares. I'll place a warning link this:

This feature doesn't work with your version of WHMCS. Please, upgrade to v.???

Now the problem is that I have no idea of what is this magic number @WHMCS ChrisD help? 🙏 7.what? It should be something between 7.6 and 7.10.

Edit: found! 7.8.0 BETA 1 CORE-13261 - Provide mergefield data to EmailPreSend hook.

 

Edited by Kian
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated