Software Developer

Insert Customer Name, Greeting to Easy Digital Downloads Purchase History Page

This is how you can display a personal greeting to the customer on the Easy Digital Downloads Purchase History page. When your Easy Digital Downloads customer is logged in to their purchase history, they will see a greeting that says, “Welcome, username.” The username displayed will be their user login. The second example, below, shows you how to instead display the customer’s first name, or their email address.

PHP

add_action( 'edd_before_purchase_history', 'before_purchase_history' );
function before_purchase_history() {
	$user = wp_get_current_user();

	if ( ! empty( $user->user_login ) ) {
		echo 'Welcome, ' . $user->user_login;
	}

}

To show the customer’s first name instead of their login user name, replace lines 5-7 with the following.

PHP

if ( ! empty( $user->user_firstname ) ) {
	echo 'Welcome, ' . $user->user_firstname;
}

To add also the customer’s email address in parenthesis next to their first name, add this to the end of the previous snippet for first name.

PHP

if ( ! empty( $user->user_email ) ) {
	echo ' (' . $user->user_email . ')';
}

By

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]