In my custom plugin, I want other user roles can also save the plugin settings. And I use settings_fields('custom_options') function to save settings.

When I am logged in as an editor or any other role, on clicking the button I am redirected to the while screen page with a message Sorry, you are not allowed to manage these options.

Please, can anyone help me with this?

Thanks in advance!


1 Answer 1


To change the capability required to save settings you can use the option_page_capability_{$option_page} filter, where {$option_page} is the value passed to settings_field() on your settings page.

So if you have this on your settings page:

<?php settings_fields( 'wpse_294802_options' ); ?>

You can change the required capability to save with the option_page_capability_wpse_294802_options filter:

function wpse_294802_option_page_capability() {
    return 'edit_pages';
add_filter( 'option_page_capability_wpse_294802_options', 'wpse_294802_option_page_capability' );

Now users with the edit_pages capability can save your settings. Just make sure that you set a matching capability when adding the settings page or the user will be able to save your settings page, but not see it.

PS: submit_button() isn't really relevant here, it's just a function that outputs an <input> element with the proper classes and text. It doesn't play a role in determining how or if settings are saved. The important part for that is settings_fields().

  • Thanks a ton for the help. It resolved my problem. Yes, thanks for directing me towards the correct path :)
    – Himani
    Feb 22, 2018 at 7:13
  • I have one more query, the above solution works only for editor role. If I try any other role example: author it gives me the error message. Is there any way to fix this?
    – Himani
    Feb 22, 2018 at 9:24
  • 1
    Well look at the answer. The code gives access to anyone who has the edit_pages capability. If you want different roles to have access use a different capability. Read about capabilities here codex.wordpress.org/Roles_and_Capabilities Feb 22, 2018 at 10:02

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.