GET FREE VERSION GET THE PRO VERSION

How To Allow Plugin Settings Page Access to Different User Roles

Learn how to allow access to the plugin settings page for different user roles.

In this article

What is the problem

By default access to Advanced Woo Search plugin settings page only has users with capability manage_options. By default it is Administrator user role.

But what if we want to allow access to this page to other user roles? For example - for Editor rule.

This is possible and below we will cover how to do that.

Plugin settings page

Plugin settings page

How to allow access for different user roles

In fact all is very simple - it is possible with the help of small custom code snippets.

But first we need to understand - what capability to specify as the minimum necessary for the user to have access to the plugin settings page.

As mentioned, by default it is manage_options. On this page you can find the list of all available capabilities divided by user roles.

So if, for example, we need to allow Editor role to view the plugin settings page ( and manage all settings ) then we can use capability edit_others_posts. This is a capability that Editor role has.

Now all that we need is to use the following custom code:

add_filter( 'aws_admin_capability', 'my_aws_admin_capability' );
function my_aws_admin_capability( $capability ) {
    return 'edit_others_posts';
}

Add this code inside your child theme functions.php file or use a special plugin for adding custom code snippets.