I'm using the Marinelli theme and want to give my main content editor access to the theme settings. Ideally just the ability to upload/change/add/subtract/enable the backgrounds of the rotating banner.

I don't see any way for them to do this without full access to the Theme settings. I was able to just give "administer themes" settings to this user and give them a shortcut to that theme. But that's still a lot of liability.

Has anyone been able to do this: limit theme configuration to just certain tasks?

1 Answer 1


You could use a hook_form_alter in your custom module.

The following assumes you already have a role called editor existing in your website.

  1. Create a mymodule folder (e.g. in http://www.example.com/sites/all/modules/custom/mymodule)
  2. Create two files in that folder. mymodule.module and mymodule.info
  3. Past the following code in mymodule.module

      function mymodule_form_alter(&$form, &$form_state, $form_id) {
      global $user;
      if ($form_id == 'system_theme_settings' && in_array('editor', array_values($user->roles))) {
        // unset the elements you don't want your content editor to have access to
        // unset($form['css3']);
        // Here we want to hide some form elements.
        // To hide/show an element we must use $element['#access'] key in the render array.
        // Using unset($element) might cause issues in form_validate and form_submit processes.
        // So instead of unset($form['css3'], $form['layout']) we set their access to FALSE
        $form['css3']['#access'] = false;
        $form['layout']['#access'] = false;
  4. Past the following in mymodule.info

    name = Mymodule
    core = 7.x

  5. Enable your module at http://www.example.com/admin/modules

  6. Clear your cache

Please note that these are the minimum requirements for creating a custom module and you should definitely read up on best practices for creating custom module at https://www.drupal.org/node/1074360

  • Well I did exactly as you said, undersound, created the exact folders, the exact files, the exact code, enabled the module, cleared cache, and logged in as editor in another browser and it didn't work. Tried loading page pjusd-drupal:8082/admin/appearance/settings/pjusd and immediately got response: Access denied You are not authorized to access this page. Is there something missing to your code?
    – Dave N
    Commented Jul 18, 2014 at 4:37
  • Does the role editor has the Administer themes permission set?
    – devunder
    Commented Jul 18, 2014 at 5:46
  • No, that's what I had added before using your suggested module. That permission setting gives the user the ability to change themes and do lots of dangerous stuff. SO I removed that permission before adding in module thinking the module would just give rights to this: pjusd-drupal:8082/admin/appearance/settings/pjusd But that didn't work and I had to add that permission back in. But again now he has rights to change all themes. I was trying to avoid that. So if there was a way to specify a specific theme and just give him a specific shortcut to it, that would be great. Dave N
    – Dave N
    Commented Jul 18, 2014 at 15:52
  • Well it all depends on how strict you want to be. If you can just provide a shortcut you can enable the permission and provide the shortcut in some custom menu or whatever. Thing is that drupal checks for that permissions on the path admin/appearance/settings and everything that comes after that. So if you realy want to prevent access to the other paths you have to override it.
    – devunder
    Commented Jul 18, 2014 at 16:25

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.