• I have a blog with a large number of authors. I would like to change the default layout of the wp-admin dashboard.

    Now I know that it is possible for the users to change the layout themselves. But is there a way to do it for them?

    I checked that changes in the dashboard result to changes in wp_usermeta table: wordpress adds a “metaboxhidden_dashboard” option where the hidden widgets are listed as an array. There is also a “closedpostboxes_dashboard” and a “wp_metaboxorder_dashboard” option (names are quite self explaining). Every user gets their own set of option when they do changes to the dashboard.

    I dont want to override the changes a user has done, but how could I change the default view?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter anttijn

    (@anttijn)

    Here’s what I’ve found out. It is possible to change the default dashboard view, but it involves hard coding.

    In wp-admin/includes/template.php, line 2864 there’s a following function:

    function get_hidden_meta_boxes($page) {
    	$hidden = (array) get_user_option( "meta-box-hidden_$page", 0, false );
    
    	// Hide slug boxes by default
    	if ( empty($hidden[0]) ) {
    		if ( 'page' == $page )
    			$hidden = array('pageslugdiv');
    		elseif ( 'post' == $page )
    			$hidden = array('slugdiv');
    
    	}
    
    	return $hidden;
    }

    So I guess that by adding something like
    elseif ('dashboard' == $page) $hidden = array('dashboard_primary', 'dashboard_secondary', 'maybe_even_some_added_plugin');
    would remove those items by default and if the user has done some changes the default settings would be overriden. The names of the items that you want to remove by default can be found for example from the dashboard.php -file.

    The problem is of course, that making changes to the code makes updating Worpdress a nightmare.

    So it would be great if the defaults would be in wp_options table so that admins could change them.

    Thread Starter anttijn

    (@anttijn)

    I wrote earlier that there is no way you could create a plugin to create default dashboard views for different roles.

    There actually is at least on way.

    You could create a plugin that works as follows:

    1. After activation you would give the different default views on an options page
    2. When you would save role specific default views the plugin would check which users have not changed their dashboard view before and add the new default options to all of these users.
    3. When you would add a new user, the plugin would use a hook to add the default dashboard options for the user depending on the role you gave her/him.
    4. When you would change users role, the plugin would check if theuser still has the old role specific default view. If the user has the default view change it to the new role specific view. If the user has made changes of her/his own dont change the view.
    5. If you would change the role specific default views, the plugin would update the new view to every user that has not made changes her/himself.

    Problem:
    The same default options is saved to the database table for every user seperately.
    I think it would be better if the default would in the database as well. But as I said this would mean changes to the code.

    The same technique could be used to create a plugin for role specific page and post views.

    I am desperately looking for a way to edit the dashboard so that my users can not see all the options I do not want them to use. Did you ever get something to work?

    PDD

    (@solharris)

    I would also be keen on a plugin solution that enabled me to choose what my users see (editors, authors etc).

    Unfortunately, it seems there is nothing around right now – unless you know of something?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to change the default dashboard layout’ is closed to new replies.