function _webform_civicrm_replaceContactLinkTokens in Webform CiviCRM Integration 7.5
Same name and namespace in other branches
- 8.5 webform_civicrm.module \_webform_civicrm_replaceContactLinkTokens()
- 7.4 webform_civicrm.module \_webform_civicrm_replaceContactLinkTokens()
Replaces contact-link tokens with civicrm contact page links
Parameters
array $tokens: Tokens to process
array $webformSubmissionData: Data submitted by the webform
Return value
array List of replaced contact-link tokens replaced with actual contacts links
1 call to _webform_civicrm_replaceContactLinkTokens()
- webform_civicrm_tokens in ./
webform_civicrm.module - Implements hook_tokens().
File
- ./
webform_civicrm.module, line 865 - Webform CiviCRM Integration Module: Links webform submissions to contacts in a CiviCRM database. @author Coleman Watts
Code
function _webform_civicrm_replaceContactLinkTokens($tokens, $webformSubmissionData) {
$replacedTokens = [];
$tokenValues = token_find_with_prefix($tokens, 'contact-link');
if (!$tokenValues) {
return $replacedTokens;
}
foreach ($tokenValues as $entityID => $tokenName) {
$tokenNewValue = '';
if (!empty($webformSubmissionData->civicrm['contact'][$entityID]['id'])) {
$contactID = $webformSubmissionData->civicrm['contact'][$entityID]['id'];
$tokenNewValue = url("/civicrm/contact/view?reset=1&cid={$contactID}", [
'absolute' => TRUE,
]);
}
$replacedTokens[$tokenName] = $tokenNewValue;
}
return $replacedTokens;
}