Author Topic: Logged on users email address in templates  (Read 4105 times)

0 Members and 1 Guest are viewing this topic.

Offline uksoreeyes

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.myleeneklass.com
Logged on users email address in templates
« on: April 12, 2003, 07:06:53 PM »
Hi have created a template called contact.html and link to it via index.php?template=contact

Now when a user is logged in I would like his/her username and email address placed in the appropriate fields. I have got the name printed ok but the email address doesn't want to work. Here is my code.

Code: [Select]
<form method=post action="thanks.php">
<table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="108">Your Name:</td>
<td width="192">
<input type="text" name="name" value="{user_name}">
</td>
</tr>
<tr>
<td width="108">Your E-mail:</td>
<td width="192">
<input type="text" name="email" value="{user_email}">
</td>
</tr>
<tr>
<td width="108" valign="top">Your Message:</td>
<td width="192">
<textarea name="message"></textarea>
</td>
</tr>
<tr>
<td width="108">&nbsp;</td>
<td width="192">
<input type="submit" name="Submit" value="Send Form">
</td>
</tr>
</table>
</form>


As you can see I have put {user_email} in the value part of the form, but it returns nothing. Anyone know what I can do?

Carl

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Logged on users email address in templates
« Reply #1 on: April 13, 2003, 04:38:51 AM »
Try this.

Open index.php and locate this near the top:
Code: [Select]
if (!empty($template)) {
  $clickstream = "<a href=\"".$site_sess->url(ROOT_PATH."index.php")."\">".$lang['home']."</a>".$config['category_separator'].str_replace("_", " ", ucfirst($template));
  $site_template->register_vars("clickstream", $clickstream);
  $site_template->print_template($site_template->parse_template($main_template));
  include(ROOT_PATH.'includes/page_footer.php');
}

Change it to:
Code: [Select]
if (!empty($template)) {
  $clickstream = "<a href=\"".$site_sess->url(ROOT_PATH."index.php")."\">".$lang['home']."</a>".$config['category_separator'].str_replace("_", " ", ucfirst($template));
  $sender_name = ($user_info['user_level'] != GUEST) ? $user_info['user_name'] : "";
  $sender_email = ($user_info['user_level'] != GUEST) ? $user_info['user_email'] : "";
  $site_template->register_vars(array(
    "sender_name" => $sender_name,
    "sender_email" => $sender_email,
    "clickstream" => $clickstream
  ));
  $site_template->print_template($site_template->parse_template($main_template));
  include(ROOT_PATH.'includes/page_footer.php');
}


Now you can use {sender_name} and {sender_email} in your template.

Offline uksoreeyes

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.myleeneklass.com
Logged on users email address in templates
« Reply #2 on: April 13, 2003, 07:54:32 PM »
Thanks for the help worked perfect.