Creating a Welcome Screen For Your WordPress Plugin
If you’ve ever updated WordPress a major version, or you’ve used a popular plugin like BuddyPress, chances are you’ve seen a plugin welcome screen.
The purpose of this screen is to get you oriented within the plugin, notify you of changes between versions and to point you to useful and relevant links.
Creating a welcome screen is easier than you may think and provides a great platform to introduce a better user experience to your product.
In this article I’ll show you how to put a welcome screen in place for your plugin. Let’s dig in!
Welcome Screen Examples
I thought it would be a good idea to show you what we’ll be doing first. Take a look at the screenshots below for welcome screens from the most recent versions of popular plugins and WordPress.
Creating Your Own Welcome Page
Most welcome screens are shown when the user clicks the activate link after installing a plugin. Since there is no mechanism to modify where that link takes the user we’ll need to resort to some cleverness. Here’s the action plan for our code:
- Create a dashboard page
- Fill it with content
- Upon activation we’ll add an option to the database
- On each admin page load we check if this option exists
- If it does we’ll redirect the user to a custom page
- Remove the dashboard page menu entry (optional)
I think seeing the full code for this will be more helpful. I’ll go through all the bits and pieces after the code block below:
The dashboard page is created on lines 26-36. The last parameter defines the function used to display the content:
welcome_screen_content. Within this function I added some HTML. If you plan on adding a whole lot of stuff in here it may be best to include a separate file.
On lines 1-4 I defined an activation hook. This runs only when a plugin is activated. It adds a transient to the database, which indicates that we should redirect to the welcome page. Why a transient? We could well have used a simple option using the
add_option() function but we want to make sure that everything is air-tight. Transients have a timeout value, I have used 30 seconds. After this time the transient is deleted – it cleans up after itself.
On lines 6-24 we add a function to
admin_init. This checks if the transient we set exists. If it does exist (and we’re not activating in bulk or from the network admin) the transient is deleted (to make sure the welcome screen is only shown once) and the user is redirected.
Finally, on lines 50-54 we remove the menu page entry from view. What this means is that even if the welcome screen is removed, the user will not see a menu entry for it under the dashboard. This is usually done since the welcome screen is not important in day-to-day usage it can safely be removed to declutter the interface.
And here’s what the welcome screen looks like:
Of course, you’ll need to add your own text and styling if you want your welcome screen to look anything like what the developers of WordPress or BuddyPress put together for their products.
That’s all you need to know for creating a customized welcome screen. I’ve packaged the code above into an actual plugin which you can download here. Take a look at the source code for the same code as you see in this article.
Once done you should make your welcome screen appealing to users by enqueueing scripts and styles. Make sure to add relevant and useful information that orients your viewers, and don’t add flashy sliders and other eye-candy just because you can.
Do you know of a plugin with an especially cool welcome screen? Did you manage to use this tutorial in your own product? Let us know in the comments below.