Force Network Admin Dashboard to 1 column on wordpress multisite

I am wondering whether anyone knows how to force the dasboard layout to 1 column on a wordpress Multisite install for the Network Admin Dashboard

This is part of the solution but it does not force the number of columns to 1:

Read More
function so_screen_layout_columns( $columns ) {
    $columns['dashboard-network'] = 1;
    return $columns;
}
add_filter( 'screen_layout_columns', 'so_screen_layout_columns' );

The following should force it but it does not work on the Network Admin Dashboard page, Anyone knows of a solution?

function so_screen_layout_dashboard() {
    return 1;
}
add_filter( 'get_user_option_screen_layout_dashboard', 'so_screen_layout_dashboard' );

Related posts

1 comment

  1. The question is how to overwrite these columns number settings in the Screen Options panel:

    columns

    Network dashboard

    When you change the number of columns in the screen options panel on the network dashboard page, you get the meta value of screen_layout_dashboard-network  saved into the wp_usermeta table:

    wp_usermeta

    In the WP_Screen class the columns number is fetched with:

    get_user_option("screen_layout_$this->id")
    

    where $this->id is dashboard-network.

    When user options are fetched with get_user_option( $option ) they are filtered through

    return apply_filters("get_user_option_{$option}", $result, $option, $user);
    

    In our case the user option is screen_layout_dashboard-network so the filter we are looking for is get_user_option_screen_layout_dashboard-network.

    You should therefore try out:

    add_filter( 'get_user_option_screen_layout_dashboard-network', 'number_of_columns' );
    
    function number_of_columns( $nr ) {
        return 1;
    }
    

    Site dashboard

    Changing the columns number on the site dashboard page, we get the meta value of screen_layout_dashboard saved into the wp_usermeta table:

    wp_usermeta

    The filter that can be used here is:

      add_filter( 'get_user_option_screen_layout_dashboard', 'number_of_columns' );
    

    ps: The screen layout settings are only saved into the database when they are changed. So for a newly installed WordPress these settings are not in the database.

Comments are closed.