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 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' );
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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.

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

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.