I started work on a new WordPress site this morning and, after creating a couple of users, quickly got bored manually setting each user’s nickname
and display_name
properties in order to display authors as “firstname lastname.” I found a few forum posts in the WordPress support forums for “how do I automatically set the display name for WordPress users?” that had partial answers but no real solutions. Then I stumbled on this article by Rares Cosma that had just what I needed.
Rares’ solution uses the user_register
WordPress action hook, which gets triggered when a new user account is registered. I modified his original version, streamlined it a bit, and applied the ‘firstname lastname’ pattern to both the display name and the nickname
attribute.