Skip to content

[5.x]: sendActivationEmail breaks other plugin template paths #17089

@MatthiasBrodelet

Description

@MatthiasBrodelet

What happened?

Description

I have a custom plugin that sends form data to a controller where a new user is created if it does not exist yet. In that case the sendActivationEmail method is used like this Craft::$app->users->sendActivationEmail($user);.

Later in the controller I also create a PDF that uses a twig template like this:

$htmlContent = Craft::$app->getView()->renderTemplate('_receipts/pdf/receipt.twig', [ 'receipt' => $receipt, ]);

For some reason when performing these actions in this order I get the error that the "_receipts/pdf/receipt.twig" template can't be found.
Commenting out the sendActivationEmail method "fixes" it.
There must be something in the sendActivationEmail method that breaks the ability to reference templates.

This did not happen in the last year so I suppose it must be related to a recent update.
The site is completely up to date.

Steps to reproduce

  1. Create new user and send the activation mail using Craft::$app->users->sendActivationEmail($user);
  2. Then try to reference another template in the plugin for a PDF or something else

Expected behavior

The template should be found.

Actual behavior

"_receipts/pdf/receipt.twig" template can't be found.

Craft CMS version

5.6.17

PHP version

8.2

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions