How to Customize the User Display Name using PHP

David Bullock — 

Memberium provides 3 filters to allow you to customize the “Display Name“, the “Nickname” and the “Nice Name“. These are separate and distinct from the Infusionsoft FirstName and LastName fields, as well as the WordPress Username.

Pro Tip
You can make all three of these names use the same name, or you can have different functions for each to produce different results.

These filters all function identically: taking the current name and an array of contact fields, and returning the new name.

The first parameter is the current display name.

The second parameter is an array of the contact’s Infusionsoft fields.

You can add your custom code to service these filters to your theme’s functions.php file.

Example 1

Below is a code sample that checks to see if the contact has tag 227 (Founder), and if so adds a suffix of (F) after the name.

Example 2

Below is a code sample that checks to see if the Infusionsoft nickname field has been set, and if so sets the Display Name to that new value.