Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

As you already discovered, the display conditions for that panel are hard-coded into a core file. It isn't meant to be changed, which means you are probably trying to use the panel for something it is not intended for. That isn't criticism. It just makes it hard. I don't see a way to change that except by editing a core file, and I don't advise that.

You can try to run the welcome_panel action on some other hook, like one of these, for example, but I wouldn't expect it to work correctly. If you really, really need the welcome_panel to run for everyone that is your best bet, but I wouldn't be hopeful.

You could also give everyone edit_theme_options capability, but that is a bad idea. I am ashamed I thought of it. :)

From what I can tell, your options are pretty limited and really boil down to "core edit". That is a high-maintenance path to start down. I'd suggest that you put your user information somewhere else, like in a new Dashboard Widget, in a Help screen, or in the admin bar.

share|improve this answer
    
Thankyou for your answer. I solved this problem in the end by hiding the old "wrap" with CSS and inserting my own "wrap" div with its own welcome panel div in at the "admin_notices" action for the dashboard page. This allowed me to do it for every user. Not the prettiest solution but it works. I could tidy it up with a regex to remove the old wrap. –  ptimson Dec 30 '12 at 17:51

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 -->
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.