Title: Question about custom code
Last modified: July 20, 2017

---

# Question about custom code

 *  [moonprox](https://wordpress.org/support/users/moonprox/)
 * (@moonprox)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/question-about-custom-code/)
 * I am using the following code to combine First name, Last name, and Username 
   to set it as a display name.
 *     ```
       add_action( 'profile_update', 'my_profile_update', 10, 2 );
       function my_profile_update( $user_id, $old_user_data ) {
               // Do something
       	$user = get_user_by( 'id', $user_id );
       	$firstname = $user->first_name;
       	$lastname = $user->last_name;
       	$username = $user->user_login;
       	if (  $firstname !== '' && $lastname !== '' ) {
       	    remove_action( 'profile_update', 'my_profile_update', 10, 2 );
       	    wp_update_user( array( 'ID' => $user_id, 'display_name' => $firstname.' '.$lastname.' '.$username ) );
       	}
       }
       ```
   
 * Typically this works fine as profile gets updated.
 * Then I realized the above code doesn’t work when when our customers are creating
   an account at the checkout page going through paypal.
 * The payment process goes like this:
 * checkout page -> click Paypal -> Page redirects to Paypal -> customers make a
   payment at paypal.com -> payment processed and click “go back to the merchant
   page” -> back to our website with “Thank you, your order is received” page
 * And I think while the checkout process goes through many steps with paypal, somehow
   the above code doesn’t work. Display name is not altered.
 * I am trying to see if there is anyway the display name could be set to first+
   last+username even they go through paypal process?

Viewing 1 replies (of 1 total)

 *  [the_wpexperts](https://wordpress.org/support/users/ukwpexperts/)
 * (@ukwpexperts)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/question-about-custom-code/#post-9345111)
 * add_action( ‘user_register’, ‘member_registration_save’, 10, 999 );
    function
   member_registration_save( $user_id ) { $user = get_user_by( ‘id’, $user_id );
   $firstname = $user->first_name; $lastname = $user->last_name; $username = $user-
   >user_login; if ( $firstname !== ” && $lastname !== ” ) { wp_update_user( array(‘
   ID’ => $user_id, ‘display_name’ => $firstname.’ ‘.$lastname.’ ‘.$username ) );}}

Viewing 1 replies (of 1 total)

The topic ‘Question about custom code’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [checkout](https://wordpress.org/support/topic-tag/checkout/)
 * [display name](https://wordpress.org/support/topic-tag/display-name/)
 * [paypal](https://wordpress.org/support/topic-tag/paypal/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 1 reply
 * 2 participants
 * Last reply from: [the_wpexperts](https://wordpress.org/support/users/ukwpexperts/)
 * Last activity: [8 years, 10 months ago](https://wordpress.org/support/topic/question-about-custom-code/#post-9345111)
 * Status: not a support question