Changing User Role Access for Admin Pages

When setting up a website for a client and trying to decide what pages of the admin they have access to, it’s helpful to know that you can easily filter most of the user-capability used to determine whether our framework admin components are accessible.

Below is a table of the default user capabilities for the admin pages added by the framework.

Item Name Item ID Default Capability
Layout Builder builder edit_theme_options
Theme Options options edit_theme_options
Theme Updates updates edit_theme_options
Widget Areas sidebars edit_theme_options

You’ll notice all items in the table above have a default capability of edit_theme_options. That means that only Administrator-role users can see them. So, if you want your client to have access to them, they’d need to be an Administrator-role user.

Or, if you’d like to create a lower-role user type for your client, but still give them access to any of our admin pages, you can use the themeblvd_admin_module_caps filter. For example, here’s one way we could give access to Editor-role users.

/**
 * Adjust admin pages to display for Editors.
 */
function my_module_caps( $caps ) {

    $caps['builder'] = 'edit_pages';
    $caps['options'] = 'edit_pages';
    $caps['sidebars'] = 'edit_pages';
    $caps['updates'] = 'edit_pages';
    
    return $caps;
}
add_filter('themeblvd_admin_module_caps', 'my_module_caps');
Note: In the above example, we’re using the capability edit_pages, but we could use any capability WordPress associates with an Editor-role user. See the WordPress Codex article, Roles and Capabilities.