Using custom variable in Bulk E-mails

nrep

Well-known member
I need to use some basic hashing in bulk e-mails, which I can do with {xen:calc} in the e-mail body - however this doesn't appear to work.

I had a look at user.php in library/XenForo/ControllerAdmin and found this fucntion:

protected function _sendEmail(array $user, array $email, Zend_Mail_Transport_Abstract $transport)

It seems to run through the 3 replacements mentioned on the bulk e-mail page:

$replacements = array(
'{name}' => htmlspecialchars($user['username']),
'{email}' => htmlspecialchars($user['email']),
'{id}' => $user['user_id']
);

Is there a way I can add my own replacement in there via an addon without modifying the core code?
 
I've been trying to get this working all day and I've read up on extending even listeners, but I don't really understand it yet.

I have created an event listener for "load class" with an event hint of "XenForo_ControllerAdmin_User" and callback "customaddon_Listener_LoadClass::_sendEmail"

In customaddon/Listener/LoadClass.php I've got:

PHP:
<?php

class customaddon_Listener_LoadClass
{
  public static function _sendEmail($class, &$extend)
  {

  if ($class == 'XenForo_ControllerAdmin_User')
  {
  $extend[] = 'customaddon_Extend_XenForo_ControllerAdmin_User';
  }

  }

}

Then, in customaddon/Extend/XenForo/Controller/Admin/user.php I've got part of the default XF user.php file, starting like this:

PHP:
<?php

/**
*
* @see XenForo_ControllerAdmin_User
*/
class customaddon_Extend_XenForo_ControllerAdmin_User extends XFCP_customaddon_Extend_XenForo_ControllerAdmin_User
{

  protected function _sendEmail(array $user, array $email, Zend_Mail_Transport_Abstract $transport)

I've then added in my hash replacement, i.e.:

PHP:
  $replacements = array(
  '{name}' => htmlspecialchars($user['username']),
  '{email}' => htmlspecialchars($user['email']),
  '{id}' => $user['user_id'],
  '{hash}' => 'xxxx' 
  );

However, when I do a test send {hash} isn't replaced. I'm sure I've done something wrong when trying to extend things, as I've never done this before, but I can't get my head round it. Am I far off?
 
Last edited:
Top Bottom