Force Network Admin Dashboard to 1 column on wordpress multisite

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)