Show Welcome Panel on Dashboard for every user

I have customised the welcome panel on the dashboard for users with information in. I then hid the “Dismiss” button and added CSS to make the welcome panel always visible. Using the ‘welcome_panel’ hook.

This works fine for Admins but the Welcome Panel is not displayed for other users such as editors and authors. Its not that the admin panel is being hidden its not included in the source code.

I need to find a way to include the welcome panel code for every user not just admins.

Just found the following in wp-admin/index.php. So it will only show if user can edit_theme_options.

<?php if ( has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) :

Is there a way to edit this or call the do_action( ‘welcome_panel’ ); even if the user cannot edit_theme_options?

2 Answers
2

This is how I solved it:

In functions.php

// Custom Dashboard
function my_custom_dashboard() {
    $screen = get_current_screen();
    if( $screen->base == 'dashboard' ) {
        include 'admin/dashboard-panel.php';
    }
}
add_action('admin_notices', 'my_custom_dashboard');

dashboard-panel.php

<!-- Hide Old Wrap with CSS -->
<style type="text/css">
div#wpcontent div.wrap {
    display: none;
}
div#wpcontent div.my-dashboard {
    display: block;
}
</style>

<!-- New Wrap with custom welcome screen-->
<div class="wrap mjp-dashboard">
    <h2>Dashboard</h2>

    <div id="welcome-panel" class="welcome-panel">
        <?php wp_nonce_field( 'welcome-panel-nonce', 'welcomepanelnonce', false ); ?>
        <?php //do_action( 'welcome_panel' ); ?>
        <div class="mjp-welcome-content">
            <h3>Welcome, <?php echo $name; ?></h3>
            <p class="about-description">Your role is...</p>
            <div class="welcome-panel-column-container">
                <div class="welcome-panel-column">

                </div>
            </div>
        </div>
    </div>

    <div id="dashboard-widgets-wrap">

    <?php wp_dashboard(); ?>

    <div class="clear"></div>
    </div><!-- dashboard-widgets-wrap -->

</div><!-- wrap -->

Leave a Comment