views:

49

answers:

2

I'm setting up Wordpress 3.0.1 for a novice user. The Dashboard widgets are appropriately placed, and I'd like them to stay that way. As far as I know, there's no add_filter or add_action hook to prevent dragging, so another approach would be to make a plugin that uses jQuery to disable dragging. What handler(s) would I override -- click, mouseUp, mouseMove, etc -- and on which DOM elements?

A: 

Use a Roles plugin like WordPress › Role Scoper « WordPress Plugins to restrict what the user can do. Not a good idea to edit core files, as your changes will get overwritten on upgrade.

songdogtech
I didn't find any capabilities related to dragging and dropping the widgets. Thanks though.
Remy
On second thought, widgets are a core WP thing, so yea, might have to hack core files.
songdogtech
A: 

Maybe the easiest thing to do is prevent the new order from being saved. This will let the user change the order, but it won't save the changes for the next time the page is loaded.

You want to prevent the meta-box-order ajax event:

add_action('check_ajax_referer', 'prevent_meta_box_order');
function prevent_meta_box_order($action)
{
    if ('meta-box-order' == $action /* && $wp_user == 'santa claus' */) {
        die('-1');
    }
}

There are probably other actions you want to prevent too. Open Firebug and check out which requests to admin-ajax.php are made when you do stuff that you would like to prevent. Or hide the Screen Options tab with CSS.

Jan Fabry