DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

Custom DisplayName

 7 Replies
 7 Subscribed to this topic
 37 Subscribed to this forum
Sort:
Author
Messages
New Around Here Send Private Message
Posts: 3
New Around Here

In Security > Member Accounts > REGISTRATION SETTINGS, I would like the Display Name Format to be [FIRSTNAME] [Profile:Infix] [LASTNAME], so that the value will be 'Cees van Dalen'.

But this doesn't work; [Profile:Infix] does not change into the actual value, instead it still reads Cees [Profile:Infix] Dalen.

I need to seperate the infix from the lastname in order to be able to correctly sort by lastname elsewhere in the website...

Can anybody help??

Kind regards, Keston Pollard
Senior Member Send Private Message
Posts: 1561
Senior Member

Hi Keston! 

You're on the right track trying to customize the Display Name Format. Unfortunately, the tokens are not parsed in the Display Name Format field—only the following core tokens are currently supported in that setting: [USERNAME], [FIRSTNAME], [LASTNAME], and [USERNAME].

If you're trying to include a custom profile property like Infix, you'll need to approach it differently. Here are a couple of options you could consider:

1. Custom Display Name Logic via Code

If you're comfortable with custom development, you could override the DisplayName logic using an IUserEventHandlers implementation. This would allow you to dynamically set the display name when the user is created or updated, including any custom profile fields.

2. Scheduled Task or Admin Tool

Alternatively, you could create a simple scheduled job or admin tool that updates the DisplayName for all users using your desired logic (FirstName + Infix + LastName). This would ensure consistency across the site and allow proper sorting.

3. Use Last Name for Sorting Instead

If your primary goal is sorting by last name elsewhere on the site (e.g., in directories), it might be more reliable to reference the LastName field directly for sorting purposes, rather than parsing the DisplayName.

I agree—it might be a nice enhancement to support profile token parsing in that field. You might consider submitting a feature request on GitHub for this.  I didn't see any existing enhancement issues for this, specifically.  Though, there is potential for low-level biography/profile hacking when exposing custom fields - which is probably why this field is current so restricted.  

Hope that helps! 

New Around Here Send Private Message
Posts: 16
New Around Here
Thanks Will, for the elaborate answer!

I think a scheduled task would be the way to go for me. Do you know of any examples in these kinds of schedules tasks?

By the way, ref to point 3, the reason I created the custom field Infix, is that in the Netherlands there's a high use of these infixes that are spelled seperate from the actual last name. Also the alphabetical sorting of the last name in the Netherlands is without the infix, that's why the plan sorting via LastName (without the Infix) was the plan all along... But since I need to call the DisplayName in several other modules it would be easier if this DisplayName would form including the Infix...
Senior Member Send Private Message
Posts: 1561
Senior Member
Posted By Keston Pollard on 5/5/2025 2:12 PM
Thanks Will, for the elaborate answer!

I think a scheduled task would be the way to go for me. Do you know of any examples in these kinds of schedules tasks?

My pleasure!  😎  

I don't have a code sample handy to do this specific task, but it seems like an easy thing to build.  For some people, a lot of the work is in getting things ready to start writing your first line of code.  If that's you, I'd suggest using the Upendo DNN Generator.  It can get you set up with a solution and then a C# class specific to DNN Scheduled Jobs.  Alternatively, if you already have a solution in place, you could still follow the same steps to get a template of a scheduler class to import into your own solution.  💪🏽

 

Veteran Member Send Private Message
Posts: 787
Veteran Member

I did not try this myself yet but...have you tried https://github.com/EasyDNNsolutions/DNNTokens?

Reason I mention this, is that although it was not our aim, tokens are being replaced in areas that were not possible yet.
The [User:DisplayName] token for instance is being replaced in the page title of meta tags like description. 

Woud not surprise me if it works in your scenario as well :-) 

New Around Here Send Private Message
Posts: 16
New Around Here

Thanks, can I just paste a costom token in the field Display Name Format (Security > Member Accounts > REGISTRATION SETTINGS)?

Veteran Member Send Private Message
Posts: 787
Veteran Member

This specific area I did not try. I guess I misunderstood your case :-)
What I did try is to put the [User:DisplayName] token as a value in the registration. In my test I pasted in the About me and the Location. Both worked.

New Around Here Send Private Message
Posts: 16
New Around Here

Just for clarification: In a default DNN install, there's no Infix field. That's why you and probably many others put your last name as 'de Waard' in the field LastName. This I'd like to prevent because your lastname starts with a W and not with a d. That's why I created the custom Infix (tussenvoegsel) profile field. Also I'd like the DisplayName be formed automatically. Unfortunately DNN does not support the use of the token [Profile:Infix] in the automatic forming of the DisplayName.

These Forums are dedicated to the discussion of DNN Platform.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
  2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
  3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  5. No Flaming or Trolling.
  6. No Profanity, Racism, or Prejudice.
  7. Site Moderators have the final word on approving / removing a thread or post or comment.
  8. English language posting only, please.

Would you like to help us?

Awesome! Simply post in the forums using the link below and we'll get you started.

Get Involved