• Hi there

    Is there a way to remove a certain roles ability to assign widgets to a page. I tried removing the Widget Wrangler meta box, but then when you create the page, it thinks you don’t want any widgets on it instead of using the ‘Default’ preset. Then when you view the page there are no widgets in the sidebar.

    Thanks

    https://www.ads-software.com/plugins/widget-wrangler/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jonathan Daggerhart

    (@daggerhart)

    Hi andyx2v,

    I’m open to suggestions for how this should be implemented.

    As a WW setting, I could allow the admin to select the minimum role required. Or, it could be a text field where the admin must type in a specific capability.

    Any other thoughts of preferences?

    Thread Starter andyx2v

    (@andyx2v)

    Hi Jonathon

    I think the standard plugin way to do this would be to create a capability, e.g. ‘ww_assign_widgets’ that would be applied to certain roles by default, e.g. Admin. Then the user has the ability to change/add this capability to whichever role they like (through Members plugin for example).

    I did fix this problem for me a while ago using the code below (which took hours!), but yeah a capability for it would be better. Thanks

    /*
     * Becuase we removed the meta box, we have to manually tell widget wrangler
     * what the preset is for this page otherwise no widgets show up on the page,
     * plugin filters (look in admin-presets.php & widget-wrangler-admin.php)
     */
    
    add_filter('widget_wrangler_save_widgets_alter', 'widget_wrangler_no_meta_box_fix', 999, 1);
    function widget_wrangler_no_meta_box_fix($widgets) {
    
    	global $widget_wrangler;
    
    	$current_preset_id = get_option('ww_post_preset_id', false);
    
    	if (!current_user_can('manage_options')) {
    
    		if ($current_preset_id === false) {
    			$widget_wrangler->presets->new_preset_id = 1;
    			if ($new_preset = $widget_wrangler->presets->get_preset(1)){
    				$widgets = serialize($new_preset->widgets);
    			}
    		} else {
    			$widget_wrangler->presets->new_preset_id = false;
    			$widgets = false;
    		}
    
    	}
    
    	return $widgets;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Ability to assign widgets to a page’ is closed to new replies.