Details
-
Type: Improvement
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Duplicate
-
Affects Version/s: 4.0.4
-
Fix Version/s: 4.0.6
-
Component/s: Core CiviCRM
-
Labels:None
Description
I just sat down to write some cool custom tokens, only to sadly discover the state of this hook, which basically makes what I was planning impractical. The queries I was planning to write are long and complex, and should only be called when needed. Unfortunately, the way this hook is implemented makes it impossible to determine if they're needed or not.
CLEANUP NEEDED:
Currently this hook takes 2 params. They are redundant, since one contains the array keys of the other. Also, apparently you are supposed to have to handle the contactIDs param if it is an array or a string, and the values param as either a single or multidimensional array. This makes using the hook unnecessarily difficult.
The function should be reduced to a single param ($values) which should always be an array of arrays, with contact ids as the array keys. The second param should be depreciated and eventually removed.
This actually may already have been done, since I have yet to see those params not be in that format, even while composing a message to a single contact.
ALLOW MODULE TO DETERMINE IF FETCHING IS NEEDED:
This should be quite simple. Instead of omitting an item from the $values array if it is empty, it should be included, with the value '' (an empty string).
For example, if you use the token
, and a given contact does not have a first name, then the $values array should include ('first_name => '') instead of omitting that item entirely, as it currently does. This means that the module can determine if a letter/email contains the token or not, and avoid running massive queries needlessly.