Pending

User tests: Successful: Unsuccessful:

avatar Fedik
Fedik
18 Jan 2026

Pull Request for Issue # .

Summary of Changes

Allow to read existing template data in the MailTemplate.

Currently it is complicated to determine the exact content is associated with MailTemplate.
Example during User registration it is impossible to load parameter from User Profile plugin in onMailBeforeRendering event to add them in to email. Because it is impossible to determine for which User it is.
The same can be for any other content associated with MailTemplate.

With new getTemplateData() it should be easy now.

Testing Instructions

Code review from Maintainers .

OR

  1. Enable Plugin User - Profile.
    Create a new User, set the profile value for Country field.

  2. Edit Email Template for "Users: Username Reminder", and change:

Your username: {USERNAME}

to:

Your username: {USERNAME}
Your country: {PROFILE.COUNTRY}
  1. Edit User Profile plugin file.

Add 'onMailBeforeRendering' => 'onMailBeforeRendering', after:

'onUserAfterSave' => 'onUserAfterSave',

And at the end of the file (before last }) add:

    public function onMailBeforeRendering(\Joomla\CMS\Event\Mail\BeforeRenderingMailTemplateEvent $event)
    {
        if ('com_users.reminder' === $event->getTemplateId()) {
            $emailTmpl = $event->getTemplate();
            $data      = $emailTmpl->getTemplateData();
            $userId    = ArrayHelper::getValue($data, 'id', 0, 'int');

            if ($userId) {
                $key   = 'profile.country';
                $db    = $this->getDatabase();
                $query = $db->createQuery()->select($db->quoteName('profile_value'))
                    ->from($db->quoteName('#__user_profiles'))
                    ->where($db->quoteName('user_id') . ' = :userid')
                    ->where($db->quoteName('profile_key') . ' = :key')
                    ->bind(':userid', $userId, ParameterType::INTEGER)
                    ->bind(':key', $key, ParameterType::STRING);
                $db->setQuery($query);

                $data[$key] = $db->loadResult() ?: '';

                $emailTmpl->addTemplateData($data);
            }
        }
    }
  1. Visit the site login form, click "Forgot your username?", and enter email of just created user and submit the form.
  2. Check email box, the email should contain country entered in Step 1.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:
  • No documentation changes for docs.joomla.org needed
  • Pull Request link for manual.joomla.org: TBD
  • No documentation changes for manual.joomla.org needed
avatar Fedik Fedik - open - 18 Jan 2026
avatar Fedik Fedik - change - 18 Jan 2026
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 18 Jan 2026
Category Libraries
avatar Fedik Fedik - change - 18 Jan 2026
The description was changed
avatar Fedik Fedik - edited - 18 Jan 2026
avatar Fedik Fedik - change - 18 Jan 2026
The description was changed
avatar Fedik Fedik - edited - 18 Jan 2026
avatar Fedik Fedik - change - 18 Jan 2026
The description was changed
avatar Fedik Fedik - edited - 18 Jan 2026
avatar exlemor exlemor - test_item - 19 Jan 2026 - Tested successfully
avatar exlemor
exlemor - comment - 19 Jan 2026

I have tested this item ✅ successfully on 77e19f7

I have successfully tested this PR.

BEFORE the PR patch, you get an error:
0 Call to undefined method Joomla\CMS\Mail\MailTemplate::getTemplateData()
which seems logical as the code is not in line elsewhere with the function that you are adding.

AFTER the PR patch, works prefectly well ;) with or without site caching, with or without Error Reporting to Simple or Maximum, no console errors either.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46711.
avatar VaishnaviSidral VaishnaviSidral - test_item - 30 Jan 2026 - Tested successfully
avatar VaishnaviSidral
VaishnaviSidral - comment - 30 Jan 2026

I have tested this item ✅ successfully on 77e19f7

I tested this issue, and it was tested successfully.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46711.

avatar pranotiTechjoomla pranotiTechjoomla - test_item - 31 Jan 2026 - Tested unsuccessfully
avatar pranotiTechjoomla
pranotiTechjoomla - comment - 31 Jan 2026

I have tested this item 🔴 unsuccessfully on 77e19f7

Please see below email content

Hello,

A username reminder has been requested for your Your Joomla! Site hosted with .net account.

Your username: username

Your country: {PROFILE.COUNTRY}

To login to your account, select the link below.

https://siteurl/index.php/component/users/login

Thank you.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46711.
avatar rbuelund rbuelund - test_item - 31 Jan 2026 - Tested successfully
avatar rbuelund
rbuelund - comment - 31 Jan 2026

I have tested this item ✅ successfully on 77e19f7

I have successfully tested this PR.

BEFORE the PR patch, we also get an error:
0 Call to undefined method Joomla\CMS\Mail\MailTemplate::getTemplateData()

After patch it works!


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46711.

avatar joomdonation joomdonation - change - 31 Jan 2026
Status Pending Ready to Commit
avatar joomdonation
joomdonation - comment - 31 Jan 2026

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46711.

Add a Comment

Login with GitHub to post a comment