1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using custom variable in Bulk E-mails

Discussion in 'XenForo Development Discussions' started by nrep, Mar 4, 2015.

  1. nrep

    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:

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

    Is there a way I can add my own replacement in there via an addon without modifying the core code?
  2. nrep

    nrep Well-Known Member

    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:


    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:


    * @see XenForo_ControllerAdmin_User
    class customaddon_Extend_XenForo_ControllerAdmin_User extends XFCP_customaddon_Extend_XenForo_ControllerAdmin_User

      protected function 
    _sendEmail(array $user, array $emailZend_Mail_Transport_Abstract $transport)
    I've then added in my hash replacement, i.e.:

      $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: Mar 4, 2015

Share This Page