There is a comprehensive article named
Extending miniBB's User Profile with the New Field(s) covering various conversions of stored values so that they display nicely on profile page, alongside forum messages, etc.
I wonder whether it is also possible to "non-destructively" pass these transformed values to e-mail templates.
Fictional scenario (similiar to my real scenario):I use the
Gender add-on, allowing users to specify their gender during registration. The value is stored as integer, 0 = none, 1 = Male, 2 = Female. I want to add this information to the e-mail template
email_admin_userregister_eng.txt, but in a readable form.
When I add the line
...
Gender: {$user_custom3}
...
to the
email_admin_userregister_eng.txt template, the generated e-mail will look like this
...
Gender: 2
...
which is not what I want to achieve.
I can add the required transformation to the
bb_func_regusr.php...
if ($emailadmin==1 and $genEmailDisable!=1) {
$genderselected=$genders[$user_custom3];$emailMsg=operate_string(Pa
rseTpl(makeUp('email_admin_userregister_'.$langOrig)), TRUE);
$sub=explode('SUBJECT>>', $emailMsg); $sub=explode('<<', $sub[1]); $emailMsg=trim($sub[1]); $sub=$sub[0];
sendMail($admin_email, $sub, $emailMsg, $reply_to_email, $reply_to_email);
}
and modify email_admin_userregister_eng.txt like this
...
Gender: {$genderselected}
...
Then it works, i.e. generated e-mail looks like this
...
Gender: Female
...
But it is not a good idea since bb_func_regusr.php is one of the core files and can be overwritten anytime during miniBB update.
I also tried to nest variables in the e-mail template definition, but the parser does not support such a thing and renders "{$genders[{user_custom3}]}" as "$genders[2]", not as "Female".
So I would like to ask about possibly better ideas on how to achieve this.