How to show customer role details in page header

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hi,
   I have different custom customer role created and assigned to different customers. What I would like to have, is to show the logged in user the current role he is assigned to, I tried following by editing Views\Common\HeaderLinks.cshtml

<li><a href="@Url.RouteUrl("CustomerInfo")" class="ico-account">@T("Admin.Customers.CustomerRoles.Fields.Name")</a></li>

no luck the header display text as 'Name'

Regards
Praveen
6 years ago
You can use this approach: http://www.strivingprogrammers.com/How-to-display-role-based-content-in-nopCommerce
6 years ago
thank you soo much , worked like charm.
5 years ago
Hi,

Above solution is working for roles Administrators and Registered

by why it dosn't work for "Forum Moderators" or "Custom role" created in admin area


  @if (EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.IsInCustomerRole("Administrators"))
  {
    <span>Administrators</span>  //this work fine
  }
  @if (EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.IsInCustomerRole("Forum Moderators"))
  {
    <span>Forum Moderators</span> //this doesn't work
  }
  @if (EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.IsInCustomerRole("Custom role"))
  {
    <span>Custom role</span> //this doesn't work
  }
  @if (EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.IsInCustomerRole("Registered"))
  {
    <span>Registered</span>   //this work fine
  }
5 years ago
It wasn't show up becouse I didn't define "System name" in CustomerRole
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.