How to Customize the User Display Name using PHP

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.

function customizeDisplayName( $display_name, $contact ) {
	$tags = explode( ',', $contact['Groups'] );

	if ( in_array( 227, $tags ) ) {
		$display_name = $display_name . ' (F)';
	}

	return $display_name;
}
add_filter( 'memberium_display_name', 'customizeDisplayName', 10, 2 );
add_filter( 'memberium_nickname', 'customizeDisplayName', 10, 2 );
add_filter( 'memberium_nice_name', 'customizeDisplayName', 10, 2 );

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.

function customizeDisplayName( $display_name, $contact ) {
	if ( ! empty( $contact['Nickname'] ) ) {
		return $contact['Nickname'];
	}
	return $display_name;
}
add_filter( 'memberium_display_name', 'customizeDisplayName', 10, 2 );
  • Was this Helpful?
  • YesNo
9 ways to add more value to your membership site

Table of Contents

Keep Reading

Debug HTTP POST

This function is used for testing HTTP POST connectivity between your WordPress membership site and your Infusionsoft app. It has no useful function other than as a testing and debugging tool.

Read More »

Memberium AutoLogin

This feature enables you to provide a link for your users to click that will automatically log them into your site without requiring them to enter their username and password. After you enter your autologin auth key and save your settings, Memberium will create example links and display them at the bottom of the Memberium > Settings > HTTP post/links page. You can copy these autologin URL’s into your email template, and edit the URL of the redirect page to reflect where you’d like your members to arrive to. Memberium also provides an example autologin link to use with Order Forms and Web Forms. Autologin links all use the same kinds of parameters, but depending on what you want to do, and where your user is linking from, you will use some parameters but not others.

Read More »

Want to get some fresh ideas on how you can improve your membership site or course?

Download our free ebook!

Book a Call

Welcome to Memberium!

We are very excited for you to be part of our family. 

We would love to answer any questions that you have!

Please choose the best time for you to get in a call with us. 

For Technical Support, you can contact us at https://keap.memberium.com/support/ or Email us at support@memberium.com.