With this StackOverflow Q&A I can't make the unregister_sidebar()
work for me.
Scenario
I have developed a theme using a sidebar area, where I've used a Widget. But I don't want the 'Editor' to get access to this Sidebar Widgetized Area in Admin area. So I want to do a tweak in my theme's functions.php
, where I previously declared register_sidebar()
somewhere to register the sidebar.
I understood that, setting a less priority will trigger the unregister function more earlier, so I tried with:
function site_unregister_sidebar() {
if ( is_admin() && current_user_can('editor') ) {
unregister_sidebar( 'my_custom_widget_area' );
}
}
add_action('widgets_init', 'site_unregister_sidebar', 1);
But nothing is happening.
- What actually I'm doing wrong?
- Is there any other way I can achieve this?
register_sidebar
runs, but lower priority means higher number.