Create a user required custom field named "test"
Show this field on registration page
Include this field in the new user mailtemplate using the code {COM_FIELDS}test{/COM_FIELDS}
Register an new user account
When user creates a new account, this placeholder in the email should be replaced with submitted value
The placeholder is replaced with a empty string
/libraries/src/Mail/MailTemplate.php
Function replaceTags handles the replacements
on line 354-360 it is missing the code to supply the replacement if this is not an array:
Change this code for a fix
foreach ($value as $subvalue)
{
if (is_array($subvalue))
{
$replacement .= $this->replaceTags($matches[1][$i], $subvalue);
}
}
to
foreach ($value as $name => $subvalue)
{
if (is_array($subvalue))
{
$replacement .= $this->replaceTags($matches[1][$i], $subvalue);
}
elseif (is_string($subvalue) && $name == $matches[1][$i])
{
$replacement .= $subvalue;
}
}
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
Not checking for field name caused a loopback error in the code.
updated code lines 354-364 /libraries/src/Mail/MailTemplate.php
foreach ($value as $name => $subvalue)
{
if (is_array($subvalue) && $name == $matches[1][$i])
{
$replacement .= implode("\n", $subvalue);
}
elseif (is_string($subvalue) && $name == $matches[1][$i])
{
$replacement .= $subvalue;
}
}
will make a PR
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-07-20 09:33:58 |
Closed_By | ⇒ | alikon |
Thank you for reporting, @keewhip .
Would you like to make a PR for your solution?