I wondering how I may hide some sections on the administration configuration page? I would like to hide some sections entirely for instance the media section and then only remove certain items for others, under the system section I only like to remove the cron item.

I tried to alter the admin/config page using hook_admin_paths_alter() and hook_preprocess_page() but without any luck. Would be nice if some one could point me in the right direction on how to achive this.

function MODULE_admin_paths_alter(&$paths) {
   // hide some paths
   $paths['admin/config/system/cron'] = FALSE;

function MODULE_preprocess_page(&$variables) {
  if(path_is_admin(current_path())) {
    // I don't know how to modify the markup of the page
    // tried to add a template called page--admin--config.tpl.php but
    // without any luck

In the end I used @Captain Pants solution:

function pe_admin_permission() {
  return array(
    'access extended config' => array(
        'title' => t('Access Extended Configurations'),
        'description' => t('Gives a user access to extended configuration pages.'),
        'restrict access' => TRUE,

function pe_admin_menu_alter(&$items) {
  // add all items you would like to hide here
  // if you hide all items in a specific section the entire block
  // will be removed
  $sections = array(

  // loop through each item you would like to hide
  foreach($sections as $section) {
    $items[$section]['access callback'] = 'user_access';
    $items[$section]['access arguments'] = array('access extended config');

I would like to achive something like this

  • Do you want these pages to be inaccessible as well (e.g. throw a 403) or just have those pages unlinkable via admin/configuration? Commented Jun 17, 2015 at 16:35
  • @CaptainPants - I think it would be enough only to remove them from the configuration page, but of course a nice feature would be to also make these paths inaccessible as well Commented Jun 17, 2015 at 17:59

4 Answers 4


You have stated that it would be "nice" to have these paths inaccessible. If a user is not supposed to have access to this paths then you should go above and beyond just "hiding links so nobody can see". Here is the solution to both remove those links from the config page AND having those links inaccessible if one were to type in the url in their address bar.

You will need to make a module with the following code. Note: I'm only doing this for the cron config page.

 * Implements hook_permission().
function my_module_permission() {

  return array(
    'access cron config' => array(
      'title' => t('Access Cron Config'),
      'description' => t('Gives a user access to the cron configuration page.'),
      'restrict access' => TRUE,

 * Implements hook_menu_alter().
function my_module_menu_alter(&$items) {

  $items['admin/config/system/cron']['access callback'] = 'user_access';
  $items['admin/config/system/cron']['access arguments'] = array('access cron config');

This will give you the "Access Cron Config" permission on the permissions page and there you can choose which role has the cron page appear for them.

Please research more on hook_permission and hook_menu_alter for clarification on how to do this for the media pages.

  • I will try this later today. The reason why I only planning to hide sections and items, is because I would like to show my users as little as possible at the configuration page, since they are very often comfused =) They would never ever use a direct path to reach any hidden item. Commented Jun 18, 2015 at 5:25
  • This solution seems to work great without changing any core files. If I use this to hide all items in a section, the entire section will be removed from the configuration page as well. Think I will stick with this and accept your answer =) Commented Jun 18, 2015 at 7:43
  • The solutions seems good to me. I would suggest to use a contrib module config_permissions drupal.org/project/config_perms to extend the permissions. you can also create the custom permissions as well. Commented Jun 23, 2015 at 11:23

Content for every section on this page is built in theme_admin_block_content function. As a solution you may copy this function into your theme template.php file and unset sections which you want to hide.

function myadminthemename_admin_block_content($variables) {
  $content = $variables['content'];
  $output = '';

  if (!empty($content)) {
    $class = 'admin-list';
    if ($compact = system_admin_compact_mode()) {
      $class .= ' compact';
    $output .= '<dl class="' . $class . '">';
    $hide_links = array(
    foreach ($content as $item) {
      if (!in_array($item['href'], $hide_links)) {
        $output .= '<dt>' . l($item['title'], $item['href'],  $item['localized_options']) . '</dt>';
        if (!$compact && isset($item['description'])) {
          $output .= '<dd>' . filter_xss_admin($item['description']) . '</dd>';
    $output .= '</dl>';
  return $output;
  • Can you update your answer with some code showing how to achive this using the mentioned theme hook? You should also edit your answer and add a link to the theme_admin_block_content() hook Commented Jun 17, 2015 at 9:08
  • Do not put this code in template.php. This will only function for a particular theme and those links will appear if the theme were to change. Commented Jun 17, 2015 at 18:49
  • @CaptainPants - Do you know if there are some module hook I can use instead of a theme hook? Right now I'm using seven as my administration theme and this theme is already using theme_admin_block_content() which means I must change the core theme files in order to achieve this. Commented Jun 18, 2015 at 7:31

You could define a new Role (say you call it sub-admin). And then you perform these extra steps:

  1. Start by granting ALL permissions to that role, so that it looks like a copy of the predefined Administrator role.

  2. For each of the sections within the administration configuration for which you want something to be removed: locate the required permission related to it, and remove that permission again for the sub-admin role.

  3. For cron within the system section, use a similar approach as in step '2.'.

  4. For users for which you want to restrict access to these admin sections, grant them the role of sub-admin, but not administrator.

With this approach you use standard Drupal techniques, based on the permission system. With probably no unexpected issues whenb upgrading to future releases (like D8?) of Drupal.

Makes sense?

  • But would this really remove the sections from the configuration page or would it only result in access denied when a user tries to access theme? Commented Jun 15, 2015 at 7:35

you could use some css to hide the sections for UX, and then use Rules or a redirect module on the paths themselves to keep people from directly entering the url.

The Rules module allows site administrators to define conditionally executed actions based on occurring events (known as reactive or ECA rules). It's a replacement with more features for the trigger module in core and the successor of the Drupal 5 workflow-ng module

You could use hook_menu_alter() instead of Rules in a custom module to keep it simple.

  • I didn't downvote. But it would be nice if you could edit your question and supply a working example. Commented Jun 19, 2015 at 12:15
  • I assume you mean answer, not question, and code would depend on the chosen path, since Rules does not use code (assuming UI), I'm not going to waste my time with code for every possible solution, if you had decided my general idea was best, I would have elaborated, but you already chose an answer, so there's little point now
    – Geoff
    Commented Jun 19, 2015 at 14:30

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.