Steve Grunwell

Open-source contributor, speaker, and electronics tinkerer

Tag: Quick Tips

Quick Tip: is_login_page() Function for WordPress

When building WordPress themes, I typically try to keep as much code as possible out of the head section of my template and instead rely on the wp_head() action hook. By putting all of my wp_register_script() and wp_register_style() calls in one function I have a single place to manage (theme) assets and their dependencies. At the bottom of the function I usually like to enqueue my global scripts and styles (ones that will always be present) but am careful to keep them from appearing in the WordPress administration area.

Continue reading→

Quick Tip: Set the Default Display Name for WordPress Users

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.

Continue reading→

Be excellent to each other.