I'd like to allow a certain user role to access the theme options only.

When I tried this in functions.php, nothing happened:

$limitedadmin = get_role('limitedadmin'); $limitedadmin->add_cap('edit_theme_options'); $limitedadmin->add_cap('edit_themes');

Then when I added this line to the above lines: $limitedadmin->add_cap('manage_options');, it gave the user role access to the theme options but also enabled access to several other options throughout the site like options to several plugins.

How can I just limit access to theme options?

  • :-/ They do look like the correct capabilities. Does switch_themes work? But at first glance I can't see why edit_theme_options doesn't. – Rup Mar 25 '19 at 12:26
  • 3
    Theoretically, the capabilities you added should handle that. edit_themes allows access to the theme editor screen, edit_theme_options allows access to to the widgets, menus, customize, background, and header screens. If your theme has a custom options panel, it would be logical to allow those capabilities to edit it, but that depends on the theme and what the theme developer allowed for their options screen. It could be that they used 'manage_options'. You could/should dig into the theme to determine that and/or ask your theme's developer about it. – butlerblog Mar 25 '19 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.