WordPress Code Snippets

A fresh mix of code snippets and tutorials

WordPress Do Stuff on First User Login


Here is a code snippet that runs the first time a user logs in to their registered account. Useful for sending custom welcome emails, or whatever.

Step 1: Add User Meta on Registration

Add the following function to your plugin or theme functions.php:

This adds an entry to the user meta that indicates that they are a new user. We will then be able to use this information in the next step.

Step 2: Check First Login and Do Something

At this point, after the user registers, their meta data will indicate that they are a new user. So now we can check that information and take action accordingly. Here is the second and final snippet required for this technique:

Add that to the same location as the previous snippet and add whatever functionality is desired for your user’s first login experience. Maybe send up some balloons or a bowl of ice cream to make it all special. A more realistic example would be to send a custom email message thanking the user for registering, etc.

Related Posts

Learn more

WordPress Themes In Depth

Show Support

Like our new Facebook Page to show support!