3

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:

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' );

1 Answer 1

3

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.

2
  • Thanks that's great works perfectly, just what I was looking for!
    – TARMAK
    Jun 26, 2013 at 7:10
  • ok great, you should consider marking the answer as accepted to close the question, thanks ;-)
    – birgire
    Jun 26, 2013 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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