how to display user name or email after login: solved
how to display user name or email after login: solved
Does anybody know how to display the user name or email of a logged in user? So that the customer could see that he is logged in as Mr. X?
Thanks,
Tony
shop.faxproducts.com
shop.blackice.com
Thanks,
Tony
shop.faxproducts.com
shop.blackice.com
Re: how to display user name or email after login
You can display the Email as
and the user first name as bello
Also note that FirstName may be empty depending that user does not specify his first name in primary address.
Code: Select all
Token.Instance.User.UserName
Code: Select all
Token.Instance.User.PrimaryAddress.FirstName
Re: how to display user name or email after login
Thanks for the tip. I think I will use the email because of the fact you mentioned that first name might not be available.
Token.Instance.User.UserName
How shall I call this, can you help with the syntax?
Thanks a lot,
Tony
Token.Instance.User.UserName
How shall I call this, can you help with the syntax?
Thanks a lot,
Tony
Re: how to display user name or email after login
Better create a user control in ConLib. Create a file UserInfo.ascx in the ConLib folder and place the following contents in it.
and then place it where ever you want to show the Email info. For example in the header scriptlet as below.
Code: Select all
<%@ Control Language="C#" ClassName="UserInfo" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if(!Token.Instance.User.IsAnonymous)
{
UserNameLabel.Text = Token.Instance.User.UserName;
}
}
</script>
<asp:Label ID="UserNameLabel" runat="server" Text="Label"></asp:Label>
Code: Select all
[[ConLib:UserInfo]]
Last edited by mazhar on Mon Oct 20, 2008 10:41 am, edited 1 time in total.
Re: how to display user name or email after login
Thanks it worked great! I added an if statement to check if the user is logged in or not, otherwise the control appeared with some cookie data instead of an email.
#if($customer.IsAnonymous)
#else
[[ConLib:Custom/UserInfo]]
#end
Thanks again,
Tony
#if($customer.IsAnonymous)
#else
[[ConLib:Custom/UserInfo]]
#end
Thanks again,
Tony
- Road Rider
- Commander (CMDR)
- Posts: 144
- Joined: Sat Jan 26, 2008 12:43 pm
- Contact:
Re: how to display user name or email after login: solved
This is what I use in my header:
Logged in as: #if($User.IsAnonymous)You are not logged in #else $User.Username #end
Simple and elegant.
Logged in as: #if($User.IsAnonymous)You are not logged in #else $User.Username #end
Simple and elegant.
Re: how to display user name or email after login: solved
Better use the current version of the above control. I have modified the control to handle the anonymous user case.
- Road Rider
- Commander (CMDR)
- Posts: 144
- Joined: Sat Jan 26, 2008 12:43 pm
- Contact:
Re: how to display user name or email after login: solved
What? They both handle it.
Re: how to display user name or email after login: solved
I am taking about this newly added statement
When first I posted the code i missed that line.
Code: Select all
if(!Token.Instance.User.IsAnonymous)
{
//
}