Customer name when logged in not email?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
In version 2.3, changing: Configuration >> All Settings (Advanced) >> customersettings.customernameformat from "ShowEmails" to "ShowFullNames" worked great in showing the customers Full Name in Blog Comments.

Can "ShowFullNames" be replaced with something else to only show the first name?

Thanks.
12 years ago
This doesn't solve the problem of getting the First name in the header links though. This is what I had to change:

Modify the HeaderLinksModel.cs file:


using Nop.Web.Framework.Mvc;

namespace Nop.Web.Models.Common
{
    public class HeaderLinksModel : BaseNopModel
    {
        public bool IsAuthenticated { get; set; }
        public string CustomerEmailUsername { get; set; }
        public bool IsCustomerImpersonated { get; set; }
        // Create a new string here
        public string CustomerFirstName { get; set; }

        public bool DisplayAdminLink { get; set; }

        public bool ShoppingCartEnabled { get; set; }
        public int ShoppingCartItems { get; set; }
        
        public bool WishlistEnabled { get; set; }
        public int WishlistItems { get; set; }

        public bool AllowPrivateMessages { get; set; }
        public string UnreadPrivateMessages { get; set; }
        public string AlertMessage { get; set; }
    }
}


then modify the CommonController.cs file:


var model = new HeaderLinksModel()
            {
                IsAuthenticated = customer.IsRegistered(),
                // Assign the customers first name to the variable
                CustomerFirstName = customer.GetAttribute<string>(SystemCustomerAttributeNames.FirstName),
                CustomerEmailUsername = customer.IsRegistered() ? (_customerSettings.UsernamesEnabled ? customer.Username : customer.Email) : "",
                IsCustomerImpersonated = _workContext.OriginalCustomerIfImpersonated != null,
                DisplayAdminLink = _permissionService.Authorize(StandardPermissionProvider.AccessAdminPanel),
                ShoppingCartEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart),
                ShoppingCartItems = customer.ShoppingCartItems.Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart).ToList().GetTotalProducts(),
                WishlistEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableWishlist),
                WishlistItems = customer.ShoppingCartItems.Where(sci => sci.ShoppingCartType == ShoppingCartType.Wishlist).ToList().GetTotalProducts(),
                AllowPrivateMessages = _forumSettings.AllowPrivateMessages,
                UnreadPrivateMessages = unreadMessage,
                AlertMessage = alertMessage,
            };


and then finally update the HeaderLinks.cshtml file:


@if (Model.IsAuthenticated)
        {
            // Change this line to use the first name from the model
            <li><a href="@Url.RouteUrl("CustomerMyAccount")" class="account">Welcome @Model.CustomerFirstName</a></li>
            <li><a href="@Url.RouteUrl("Logout")" class="ico-logout">@T("Account.Logout")</a></li>
            
            if (Model.AllowPrivateMessages)
            {
            <li><a href="@Url.RouteUrl("PrivateMessages", new { tab = "" })" class="ico-inbox">@T("PrivateMessages.Inbox")</a>
                @Model.UnreadPrivateMessages</li>
                if (!string.IsNullOrEmpty(Model.AlertMessage))
                {
                    //using $(document).bind instead of $(document).ready to execute the alert after tabs load (on privatemessages page)
            <script type="text/javascript">
                $(document).bind("ready", function () {
                    alert('@Model.AlertMessage');
                });
            </script>
                }
            }
        }
11 years ago
Sir,
can you please tell me how to get fname, lname and phone no of logged in customer
11 years ago
@redmorello...or anybody else of genius quality.

  Your instructions worked like a charm. After a quick rebuild, I got the first name to appear within the Headerlinks. Unfortunately, the change caused the My Account page to go belly up. It keeps the proper layout page, but doesn't pull in the Customer Navigation needed to...well...navigate. Just blank.

  I assume that a variable change or two needs to be made in the CustomerController.cs, but that's a long list and I look to launch this weekend--don't need to go FUBAR before I do so.

  Any idea what I need to add and where. As always, thanks in advance. Peace and a Twinkie.
11 years ago
Hello,

My "customersettings.customernameformat" was already set to "ShowFullNames" and yet shows email. I don't have the code behind because I bought a template that didn't provide the source code.

Any other ideas for getting customers Fist/Last Names to show instead of email, when logged in?

Thanks in advance.
11 years ago
Across the whole site or just certain sections? It's my understanding that there's not a full sweep fix. And if you "bought" this, there is no telling what was stripped out or modified. You may not have the option to do so anymore.
9 years ago
Hello Guys
I have tried all solutions and have figured that none of them works on 3.40
Does anyone know how to edit 3.40 files?
Regards
Iman
9 years ago
Did anybody ever get this to work in 3.50?

I tried checking the " 'Usernames' enabled: " and setting the "Customer name format:"  to Show usernames.  It still shows email address.

What is the purpose of 'Usernames' enabled: and Customer name format:?

Thanks,
Tony
8 years ago
I join to this question. First Name, Full name doesn't work (3.60).
8 years ago
How to do the same with Nopcommerce 3.7? i search for Module folder. it is not present in nop 3.7. Please help. i want to First name insted of Email in header.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.