wp update message on multisite

Dear,

Is it possible to show the wordpress messages only on main site and not to each subsites?

You know the way every time there is a new wp version or any other message actually… those appear on the dashboard of each subsites…

It would be good to limit those messages only to the main site dashboard.

Do you know if this is possible?

Thanks,

Paddy

  • Dimitris
    • Support Star

    Hey there Paddy,

    hope you’re doing good and thanks for reaching us! :slight_smile:

    I just created this little MU plugin for you, which detects current blog ID and inserts a little CSS rule to hide admin messages if not the main blog.

    Simply create a new PHP file in your installation like

    /wp-content/mu-plugins/remove-admin-notices.php (create the mu-plugins folder if doesn’t exist) and use the following snippet in there (please mind not to have any gaps or empty lines before the opening php tag).

    <?php
    add_action('admin_head', 'remove_admin_notices', 11);
    function remove_admin_notices(){
    $blog_id = get_current_blog_id();
    if ( $blog_id != 1 ) { // change 1 to the ID of your main site if not 1
    add_action('admin_head', 'remove_admin_notices_css', 12);
    }
    }
    function remove_admin_notices_css() {
    echo '<style>
    .notice {
    display: none;
    }
    </style>';
    }

    You may also need to add some additional CSS classes apart from the “.notice” I used in my example. :wink:

    Warm regards,

    Dimitris

  • Paddy
    • The Bug Hunter

    Hi Dimitris,

    Thanks for this.

    I created it in the folder mentioned above.

    But when I go on a subsite the admin notice is still there.

    Please see the screenshot.

    I confirm that my main blog id is = 1.

    I cleared the cache after adding your code but the message is still there.

    Should I add something else to avoid those update message on subsites?

    Thanks,

    Paddy

  • Dimitris
    • Support Star

    Hello Paddy,

    it seems that this message isn’t wrap in a “notice” class but in a “update-nag” instead.

    Could you please try to replace in previous snippet

    .notice {

    with

    .notice,
    .update-nag {

    Clear all caches and give this another try. :slight_smile:

    Warm regards,

    Dimitris

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.