CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Add Joomla username token - CiviCRM bug, or problem with my hook implementation?
Pages: [1]

Author Topic: Add Joomla username token - CiviCRM bug, or problem with my hook implementation?  (Read 532 times)

nigel_currie

  • I’m new here
  • *
  • Posts: 21
  • Karma: 1
Add Joomla username token - CiviCRM bug, or problem with my hook implementation?
January 06, 2014, 02:35:59 pm
Hello,

I'm implementing the tokenValues() and token() hooks to allow the addition of the joomla username to emails in CiviMail. It works fine for plain-text, but it gets omitted on the html version when I send a test email. It does the token replace for both html and plain-text in the preview, so am wondering if this is a bug...

Implementation as follows:
Code: [Select]
/**
 * Hook to add username token
 */
function richmondcustom_civicrm_tokens(&$tokens) {
$tokens['joomla'] = array(
'joomla.username' => 'Joomla: username',
);
}

/**
 * Hook to populate joomla.username from database
 */
function richmondcustom_civicrm_tokenValues(&$values, $cids, $job = null, $tokens = array(), $context = null)
{
$contacts = implode(',', $cids);

$dao = &CRM_Core_DAO::executeQuery("
SELECT username, contact_id
FROM joomla_users
INNER JOIN civicrm_uf_match on uf_id=joomla_users.id
WHERE contact_id IN ($contacts);"
);

while ($dao->fetch()) {
$cid = $dao->contact_id;

$values[$cid]['joomla.username'] = $dao->username;
}
}


Not sure where I'm going wrong. Guidance gratefully received!
« Last Edit: January 06, 2014, 03:16:05 pm by nigel_currie »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Add Joomla username token - CiviCRM bug, or problem with my hook implementation?
January 06, 2014, 09:44:49 pm

can u add some debug statements here:

CRM_Mailing_BAO_Mailing::tokenReplace

and see why text tokens are replaced but not html tokens

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Add Joomla username token - CiviCRM bug, or problem with my hook implementation?

This forum was archived on 2017-11-26.