{"id":9337866,"date":"2017-07-20T19:52:47","date_gmt":"2017-07-20T19:52:47","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/question-about-custom-code\/"},"modified":"2017-07-20T19:52:47","modified_gmt":"2017-07-20T19:52:47","slug":"question-about-custom-code","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/question-about-custom-code\/","title":{"rendered":"Question about custom code"},"content":{"rendered":"<p>I am using the following code to combine First name, Last name, and Username to set it as a display name.<\/p>\n<pre><code>add_action( &#039;profile_update&#039;, &#039;my_profile_update&#039;, 10, 2 );\nfunction my_profile_update( $user_id, $old_user_data ) {\n        \/\/ Do something\n\t$user = get_user_by( &#039;id&#039;, $user_id );\n\t$firstname = $user-&gt;first_name;\n\t$lastname = $user-&gt;last_name;\n\t$username = $user-&gt;user_login;\n\tif (  $firstname !== &#039;&#039; &amp;&amp; $lastname !== &#039;&#039; ) {\n\t    remove_action( &#039;profile_update&#039;, &#039;my_profile_update&#039;, 10, 2 );\n\t    wp_update_user( array( &#039;ID&#039; =&gt; $user_id, &#039;display_name&#039; =&gt; $firstname.&#039; &#039;.$lastname.&#039; &#039;.$username ) );\n\t}\n}<\/code><\/pre>\n<p>Typically this works fine as profile gets updated.<\/p>\n<p>Then I realized the above code doesn&#8217;t work when when our customers are creating an account at the checkout page going through paypal.<\/p>\n<p>The payment process goes like this:<\/p>\n<p>checkout page -&gt; click Paypal -&gt; Page redirects to Paypal -&gt; customers make a payment at paypal.com -&gt; payment processed and click &#8220;go back to the merchant page&#8221; -&gt; back to our website with &#8220;Thank you, your order is received&#8221; page<\/p>\n<p>And I think while the checkout process goes through many steps with paypal, somehow the above code doesn&#8217;t work.  Display name is not altered.<\/p>\n<p>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?<\/p>\n","protected":false},"template":"","class_list":["post-9337866","topic","type-topic","status-publish","hentry","topic-tag-checkout","topic-tag-display-name","topic-tag-paypal","topic-tag-php"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9337866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9337866\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=9337866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}