Forums

Email template problem

Bullfn33 03 Aug, 2008
I'm sending my form results to the user's email with a template I made. The only problem I have is that I'm trying to add the user's username to the template but it will not insert their username into the {username} code. It shows up as is. The username field in the form is a hidden field and it is pulling the username from the Joomla user database so I don't know if maybe that might be why it's not transferring. All the other field names inside their brackets transfer over to the template just fine. Any ideas?
GreyHead 03 Aug, 2008
Hi bullfn33,

If you turn Debug on does the username show up correctly in the $_POST array at the top of the page?

A hidden field is usually treated exactly like any other field. The most likely reasons for it not showing up (a) a mismatch of fieldnames somewhere, or (b) that value isn't being captured into the hidden field.

Bob
Bullfn33 03 Aug, 2008
When you ask does it show correctly, do you mean does is display username or the actual username?
Here is the first part which shows both of the hidden fields on the form:
_POST: Array ( [username] => {username} [user_email] => {user_email}


The username is captured in the submitted data but not in the email template.

Here is the top part of the email template where you can see the username was not captured:

From: Admin [admin@cfbpredictions.com]
To: user_email, [email]admin@cfbpredictions.com[/email]
Subject: Top 25 Weekly Challenge Entry - CFBPredictions.com


{username}, here is your entry for WEEK 1 of the Top 25 Weekly Challenge!

GreyHead 03 Aug, 2008
Hi bullfn33,

It looks as though the value of the hidden field is set to '{username}'. Those curly brackets won't work in the form html itself - only for the form results after the form is submitted. You'll need something like this in the form html:
<?php
global $my;
?>
<input type="hidden" name="username" value="<?php echo $my->username; ?>" />
<input type="hidden" name="user_email" value="<?php echo $my->email; ?>" />

Bob
Bullfn33 03 Aug, 2008
Using this, what would I write into the email template for the username field value to show up?
GreyHead 04 Aug, 2008
Hi bullfn33,

In the email template you can use {username} - but not in the form html, or anywhere else come to that.

Bob
Bullfn33 04 Aug, 2008
When I put {username} into the email template nothing shows up in its place, just a blank spot where it should be.
Max_admin 04 Aug, 2008
then this field didn't have any values posted!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Bullfn33 04 Aug, 2008

then this field didn't have any values posted!



The value for this field that I'm trying right now is what GreyHead told me to try which is <?php echo $my->username; ?> What value should I try to get it to post?

It is posting the username to the results table but not the email template. It is a hidden field that is pulling the user's username from the Joomla database onSubmit.
Max_admin 04 Aug, 2008
Hi Bullfn, are you using the latest v3.0 BETA ? if the value is stored in DB then its posted! let me know the answer for the first question!

Regards,

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Bullfn33 04 Aug, 2008
I'm using 2.5 J1.5 RC3.1.
Max_admin 04 Aug, 2008
Then you have J1.5 and Bob's code is for J1.0.x, use this instead :

    <?php
    $my =& JFactory::getUser();
    ?>
    <input type="hidden" name="username" value="<?php echo $my->username; ?>" />
    <input type="hidden" name="user_email" value="<?php echo $my->email; ?>" />
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Bullfn33 05 Aug, 2008
That worked! thanks guys 🙂
This topic is locked and no more replies can be posted.