How to confirue the Dashboard Widget Order for all sub-sites

Hello, i'd like to know how I can configure the Dashboard Widget Order Plugin to arrange the widgets for all sub-sites on a WPMU.

I have installed and setup the plugin, and the widget on my primary site is displayed in the correct place.

I'd like to have the same widget displayed in the same place on all my sub-sites.

I currently see the widget on all my sites, however other than my primary site, the widget is displayed at the bottom of the page.

I've tried looking at the code, and can't seem to find where to do this exactly.

Any help would be much appreciated.

Thank you for your help and support in advance,

Regards.

  • Nicholas

    Hi PC, thank you for your reply. Very much appreciated.

    Within the .php file i have several link such as:

    //  change the order of the widgets here
    $dashboard_widgets_order['normal']['core'][] = 'dashboard_right_now';
    $dashboard_widgets_order['column1']['high'][] = 'dashboard_plugins';
    $dashboard_widgets_order['normal']['core'][] = 'dashboard_activity';
    $dashboard_widgets_order['normal']['default'][] = 'dashboard_incoming_links';
    $dashboard_widgets_order['side']['core'][] = 'dashboard_quick_press';
    $dashboard_widgets_order['side']['default'][] = 'dashboard_primary';
    $dashboard_widgets_order['column3']['high'][] = 'dashboard_secondary';

    I have tried changing the order of them, also tried setting them up identically as the Usage page displays them, and still no luck.

    Am i missing something, or not doing something correctly?

    Thanks for your help.

  • PC

    Hey there Nick and JT,

    Thanks for posting back.

    When you change the order of the widgets, it only gets applicable to a new user and not the existing ones.

    If you want to change it for the existing users follow the below instruction :

    //  Change this if you update the widget order and want all users to have
    //  the new order instead of just new users.
    //  Note that this will overwrite the custom widget order users have
    //  configured.
    $dashboard_widgets_order_hash = 'm9c0u203b0u0338u10zxnm1lm';

    So you can change the value of hash to something else. May be a few characters here and there. I tried and it seemed to work fine for me.

    But I was not able to move the quick press widget. Let me just discuss it with our developers team once as well.

    They should be around soon.

    Cheers, PC

  • Nicholas

    Hi Mac, thanks for your help. Really appreciate it.

    I've tried changing the hash order, and still not able to get the custom widget to be at the top.

    Tried adding a few characters here and there, and removing some and still nothing.

    I have a custom widget within the dashboard I'd like to be at the top and just can't seem to find a way how.
    If i login as a user, refresh the browser the widget are still in there normal layout, and not moving no matter how i oder the widget within the widget order .php file.

    Thanks again.

  • Hoang Ngo

    Hi @Nicholas,

    I hope you are well today and I'm sorry about the issue.

    Because Wordpress allow user to manual update the Dashboard Widgets, so we have the hash order, which work like a signal, to tell the plugin we want the widgets order update.

    So every time, after we update the widget code, we need to update the hash to.

    I can not reproduce the issue on my labs, so could you enable support staff login in WPMU DEV dashboard > support > support access > grant access, please?

    Best Regards,
    Hoang

  • Nicholas

    Hi Hoang,

    Thank you for your reply and support.

    I have enable the support login for you to take a look.

    The widget i'd like to place at the top is the custom widget I have created using your custom widget plugin.

    Currently for any site created it is shown at the bottom of the dashboard page, i'd like this to be the first widget they see, rather than the current "At a glance" or "Activity" widgets.

    If you need anything from me, please don't hesitate to ask,

    Again thanks.

  • Hoang Ngo

    Hi @Nicholas,

    I hope you are well today and thanks for your information.

    I have checked your site, I assume the widget "Get your FREE English Portfolio Here!" is the widget you need to make it on top.

    So please update the order too

    $dashboard_widgets_order['normal']['high'][] = 'custom_content_dashboard_widget'
    $dashboard_widgets_order['normal']['core'][] = 'dashboard_right_now';
    $dashboard_widgets_order['column1']['high'][] = 'dashboard_plugins';
    $dashboard_widgets_order['normal']['core'][] = 'dashboard_activity';
    $dashboard_widgets_order['normal']['default'][] = 'dashboard_incoming_links';
    $dashboard_widgets_order['side']['core'][] = 'dashboard_quick_press';
    $dashboard_widgets_order['side']['default'][] = 'dashboard_primary';
    $dashboard_widgets_order['column3']['high'][] = 'dashboard_secondary';

    This will push your custom widget to the top.

    Please give it a try and let us update :slight_smile:

    Best Regards,
    Hoang

  • Nicholas

    Hi Hoang,

    Thank you for your help.

    When I try to use the order in your suggestion above, i get the following error;

    Parse error: syntax error, unexpected '$dashboard_widgets_order' (T_VARIABLE) in /var/www/wp-content/plugins/dashboard-widgets-order/dashboard-widgets-order.php on line 44

    If I use the default file from the plugin the error isn't present and the plugin works.

    i have copied the file for you to take a look as to why I might be getting this error;

    <?php
    /*
    Plugin Name: Dashboard Widgets Order
    Plugin URI: https://premium.wpmudev.org/project/dashboard-widget-order
    Description: Easily customize the order of widgets on all of your users dashboards... giving more prominence to the widgets *you* want them to see and use
    Author: S H Mohanjith (Incsub), Andrew Billits (Incsub)
    Version: 2.0.4.2
    Author URI: https://premium.wpmudev.org
    WDP ID: 16
    Network: true
    Text Domain: dashboard_widgets_order
    */
    
    /*
    Copyright 2007-2009 Incsub (http://incsub.com)
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by
    the Free Software Foundation.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    */
    
    $dashboard_widgets_order = array();
    $dashboard_widgets_order['normal'] = array('high' => array(), 'core' => array(), 'default' => array(), 'low' => array());
    $dashboard_widgets_order['side'] = array('high' => array(), 'core' => array(), 'default' => array(), 'low' => array());
    $dashboard_widgets_order['column3'] = array('high' => array(), 'core' => array(), 'default' => array(), 'low' => array());
    $dashboard_widgets_order['column4'] = array('high' => array(), 'core' => array(), 'default' => array(), 'low' => array());
    
    //------------------------------------------------------------------------//
    //---Config---------------------------------------------------------------//
    //------------------------------------------------------------------------//
    //  change the order of the widgets here
    
    $dashboard_widgets_order['normal']['high'][] = 'custom_content_dashboard_widget'
    $dashboard_widgets_order['normal']['core'][] = 'dashboard_right_now';
    $dashboard_widgets_order['column1']['high'][] = 'dashboard_plugins';
    
    $dashboard_widgets_order['normal']['core'][] = 'dashboard_activity';
    $dashboard_widgets_order['normal']['default'][] = 'dashboard_incoming_links';
    
    $dashboard_widgets_order['side']['core'][] = 'dashboard_quick_press';
    $dashboard_widgets_order['side']['default'][] = 'dashboard_primary';
    $dashboard_widgets_order['column3']['high'][] = 'dashboard_secondary';
    
    //  Change this if you update the widget order and want all users to have
    //  the new order instead of just new users.
    //  Note that this will overwrite the custom widget order users have
    //  configured.
    $dashboard_widgets_order_hash = 'm9c0u203b9u0338u10zxnm1lm';
    
    //------------------------------------------------------------------------//
    //---Hook-----------------------------------------------------------------//
    //------------------------------------------------------------------------//
    add_action('init', 'dashboard_widgets_order');
    //------------------------------------------------------------------------//
    //---Functions------------------------------------------------------------//
    //------------------------------------------------------------------------//
    
    function dashboard_widgets_order() {
    	global $wpdb, $user_ID, $dashboard_widgets_order, $dashboard_widgets_order, $dashboard_widgets_order_hash, $wp_meta_boxes;	  		   					 	 	 	
    
    	if ( !is_multisite() )
    		exit( 'The Dashboard Widget Order plugin is only compatible with WordPress Multisite.' );
    
    	load_plugin_textdomain('dashboard_widgets_order', false, dirname(plugin_basename(__FILE__)).'/languages');
    
    	if ( !empty( $user_ID ) ) {
    		$dashboard_widget_order_updated = get_user_option('meta-box-order_dashboard_updated', $user_ID);
    
    		if ( $dashboard_widget_order_updated != $dashboard_widgets_order_hash ) {
    
    			$dashboard_widget_order = array();
    
    			foreach ( $dashboard_widgets_order as $location => $sidebar ) {
    
    				if (!isset($dashboard_widget_order[$location])) {
    					$dashboard_widget_order[$location] = array();
    				}
    
    				foreach (array('high', 'core', 'default', 'low') as $priority) {
    					if (count($sidebar[$priority]) > 0) {
    						$dashboard_widget_order[$location][] = join(',', $sidebar[$priority]);
    					}
    				}
    				$dashboard_widget_order[$location] = join(',', $dashboard_widget_order[$location]);
    			}
    
    			update_user_option($user_ID, 'meta-box-order_dashboard', $dashboard_widget_order, true);
    			update_user_option($user_ID, 'meta-box-order_dashboard_updated', $dashboard_widgets_order_hash, true);
    		}
    	}
    }

    Thank you for your help.

  • Hoang Ngo

    Hi @Nicholas,

    I'm really sorry for this issue, the addition code should be

    $dashboard_widgets_order['normal']['high'][] = 'custom_content_dashboard_widget';
    $dashboard_widgets_order['normal']['core'][] = 'dashboard_right_now';
    $dashboard_widgets_order['column1']['high'][] = 'dashboard_plugins';
    
    $dashboard_widgets_order['normal']['core'][] = 'dashboard_activity';
    $dashboard_widgets_order['normal']['default'][] = 'dashboard_incoming_links';
    
    $dashboard_widgets_order['side']['core'][] = 'dashboard_quick_press';
    $dashboard_widgets_order['side']['default'][] = 'dashboard_primary';
    $dashboard_widgets_order['column3']['high'][] = 'dashboard_secondary';

    Best Regards,
    Hoang

  • Nicholas

    Hi Hoang,

    Perfect! The last set of code worked. Also changed the order_hash and all current users widgets updated.

    I think it would be really worth putting all of this into the manual, as it's not as clearer as what this thread has.

    Especially adding extra lines of code for specific widgets for example;

    $dashboard_widgets_order['normal']['high'][] = 'custom_content_dashboard_widget';

    Might be worth noting that in the manual, that if you are also using WPMU-CUSTOM-WIDGET plugin to use this line.

    Any help I can be regarding the manual, more than happy to help.

    Many thanks for your help and support on this one, and to @Mac as well.

    If there is anything else you need from me please don't hesitate to ask, otherwise you can make this as closed.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.