WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working in wordpress multi site, but this question is relevant for regular use in wordpress.

How can I hide certain sidebars from certain user groups (e.g. editors or admins) ? I have already tried the trivial:

    if(is_admin() && user_can(...)){

But this doesn't hide the sidebar, it shows that this sidebar is not active and the editor, for that matter, can still drag in and out as he or she pleases.


share|improve this question
hide where? on the admin side or front end? – Bainternet Jun 26 '12 at 21:36
In the admin. I want to allow admins control over 2 widget areas, when actually superadmins can control 4 widget areas. The users seee them all. – Nadav Jun 28 '12 at 15:50
up vote 0 down vote accepted

I am assuming you mean to limit access to edit a sidebar in the admin interface, not to remove it on the theme.

Without getting to deep into how the widgets/sidebar framework functions behind the scenes, your best bet is going to be to fiddle with the $wp_registered_sidebars global. However, the key is when - too early and the wp-admin/widgets.php template will see the missing sidebar and move it over to the Inactive Sidebars 'sidebar'. Too late and, well, you get no effect.

add_action('widgets_admin_page', 'sidebar_capabilities');

 * Keep in mind that you can certainly create custom
 * capabilities for your sidebars. You could create a loop
 * that generates new capabilities for each sidebar and assigns them
 * to admin. You could then manage those capabilities for other 
 * users with the Members plugin by Justin Tadlock
function sidebar_capabilities(){
    global $wp_registered_sidebars;

    //Remove the comment lines to see the global variable structure.

    //Use whatever capabilities you want. 
    //To test as admin, just put junk text for the cap.
    if(is_admin() && !current_user_can('edit_plugins')){

        //This sidebar name is from the twenty-ten theme.
share|improve this answer
Thanks, It seems to be working! – Nadav Jun 28 '12 at 11:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.