When editing the setting of a block you can specify Themes and Regions where the block is going to be shown.

I need to hide some Region and a Theme for a given role? Can I do this?

I tried with http://drupal.org/project/block_access but is not useful for this.


3 Answers 3


You can do it with dirty fix:

Add body class for required role(s), and hide with css conditions.

  • I already thought of doing in that way. How do I add the role as class in the body?
    – chefnelone
    Commented Apr 16, 2013 at 14:43
  • themplate_preprocess_page(&$vars) Commented Apr 19, 2013 at 10:02

it's a bit late but for the people in the same situation :

function MODULE_form_alter(&$form, &$form_state, $form_id){
    global $user;
    if($form_id == 'block_admin_configure'){
            hide($form['visibility']); //for the visibility region
            hide($form['visibility_title']); //for the visibility region

To change the Region & Theme output, first locate the settings in the Block Module block.admin.inc file on line 297. Adjust region and theme by adding logic (like an if statement for user permissions).

You can use the following snippet as a starting point or start from scratch if you are comfortable writing it from the ground-up.

Include the following snippet in a hook_form_alter() function.

$theme_default = variable_get('theme_default', 'bartik');
  $admin_theme = variable_get('admin_theme');
  foreach (list_themes() as $key => $theme) {
    // Only display enabled themes
    if ($theme->status) {
      $region = db_query("SELECT region FROM {block} WHERE module = :module AND delta = :delta AND theme = :theme", array(
        ':module' => $block->module,
        ':delta' => $block->delta,
        ':theme' => $key,

      // Use a meaningful title for the main site theme and administrative
      // theme.
      $theme_title = $theme->info['name'];
      if ($key == $theme_default) {
        $theme_title = t('!theme (default theme)', array('!theme' => $theme_title));
      elseif ($admin_theme && $key == $admin_theme) {
        $theme_title = t('!theme (administration theme)', array('!theme' => $theme_title));
      $form['visibility']['regions'][$key] = array(
        '#type' => 'select',
        '#title' => $theme_title,
        '#default_value' => !empty($region) && $region != -1 ? $region : NULL,
        '#empty_value' => BLOCK_REGION_NONE,
        '#options' => system_region_list($key, REGIONS_VISIBLE),
        '#weight' => ($key == $theme_default ? 9 : 10),

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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