Categories
Tutorial Uncategorized WordPress

How to Hide or Replace the WordPress Welcome Panel

Updated: now with more in-depth code!

So you want to modify the WordPress Dashboard Welcome Screen

There was a thread on the WPMU website that discusses how to disable the WordPress welcome screen, but the code provided didn’t work, so I figured I’d show how to do it!

The `wp_welcome_panel()` function uses the `show_welcome_panel` user meta setting to determine whether or not to show the welcome panel.  In order to modify this setting, we’re going to add a filter to the `get_user_metadata` filter, which uses the `get_metadata` function.

The following code snippets should be added to your theme’s `functions.php` file.

Disable the dashboard welcome screen…

This will only hide the panel, not replace it with any other content.

add_filter("get_user_metadata", "my_own_welcome_panel", 1, 4);

function my_own_welcome_panel($null, $object_id, $meta_key, $single) {
	if($meta_key === 'my_own_welcome_panel') { return 0; }
}

or Show Your Own Panel

You can replace the WP welcome panel with your own content using this snippet.

add_filter("get_user_metadata", "my_own_welcome_panel", 1, 4);
function my_own_welcome_panel($null, $object_id, $meta_key, $single) {

	// Only work with the show_welcome_panel
	if($meta_key !== 'show_welcome_panel') { return null; }

	// If the user has already said they don't want to see the panel, don't show it!
	$show_panel = get_user_meta( get_current_user_id(), 'my_own_welcome_panel', true );
	if(empty($show_panel)) { return 0; }

	// Echo your HTML or content here, but make sure to have a link like the following:
	?>
	<a class="welcome-panel-close" href="<?php echo esc_url( admin_url( '?my_own_welcome=0' ) ); ?>"><?php _e('Dismiss this Message'); ?></a>
	<?php

	// Return 0 or else the original welcome panel will show as well.
	return 0;
}

// Add the functionality to update the user's settings with whether or not they have closed the panel
add_action('admin_init', 'my_own_welcome_set_welcome_panel');
function my_own_welcome_set_welcome_panel() {
	if ( isset( $_GET['my_own_welcome'] ) ) {
		update_user_meta( get_current_user_id(), 'my_own_welcome_panel', intval($_GET['my_own_welcome']));
	}
}

By Zack Katz

Zack Katz is the founder of GravityKit and TrustedLogin. He lives in Leverett, Massachusetts with his wife Juniper.

5 replies on “How to Hide or Replace the WordPress Welcome Panel”

Shakopee is a popular suburb of Minneapolis, 
Minnesota, 
and Shakopee 
homes for sale often move very quickly on the market. This is because
 Shakopee MN real estate is highly desirable, since the town offers
 easy access to Minneapolis while still preserving the 
small-town … 
charm that it is known for. Are you thinking of moving to Shakopee?
 You’ve come to the right place.

I’m finding that when doing this: 1. you lose the ability to dismiss the screen… which I’ve almost worked around by using a different usermeta field that is updated every time the ‘show_welcome_screen’ meta is updated. but the more insurmountable 2. is that the whole welcome screen shows up in the ‘Screen Options’ tab at the top of the page… and again the checkbox is permanently unchecked since we’re returning 0 at the end of the filter. My only ideas for fixing this would then be either CSS or JS ‘hacks’.

what is really needed are more Hooks/filters in the admin side.

Great code! I want to make my own welcome panel and use the second own you’ve posted. But, my problem is that it only shows for admins (and i want to show it for authors). Have you any tip how I say and if current_user_can publish posts or something like that?

Comments are closed.