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?
- The topic ‘Question about custom code’ is closed to new replies.