JoryHogeveen / view-admin-as

View the WordPress admin as a different role, switch between users, temporarily change your capabilities, set default screen settings for roles, manage your roles and capabilities.

Home Page:https://wordpress.org/plugins/view-admin-as/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Customizing a role?

paaljoachim opened this issue · comments

Hey

I happen to bump into this repo and I am taking a look at your plugin.
It would be nice rename roles and customize them.
For instance creating a client/customer/owner role hiding the plugins sidebar tab. Hiding Appearance -> Editor etc.

Hi @paaljoachim,

Renaming roles is already possible. The only other customization for a role is it's capabilities, which is also possible :-).
WP has no other data attached to roles.

For instance creating a client/customer/owner role hiding the plugins sidebar tab. Hiding Appearance -> Editor etc.

The Appearance menu item is linked to the capability edit_theme_options by default but it's submenu items do not have their own capabilities in WordPress.

There are some plugins which allow you to fully customize the menu's in WP based on roles etc. or you can use some custom code.

Plugin: https://wordpress.org/plugins/admin-menu-editor/

In your specific case (disabling the editor for a role), please check https://codex.wordpress.org/remove_submenu_page and choose which items to remove.
You can wrap the code in this:

add_action( 'admin_menu', 'custom_remove_menu_items', 999 );
function custom_remove_menu_items() {
    $user = wp_get_current_user();
    if ( in_array( 'YOUR_ROLE', $user->roles ) ) {
        // Remove the menu items. For example the widgets item:
        remove_submenu_page( 'themes.php', 'widgets.php' );
    }
}

For now a feature like this is out of scope for this plugin as it is not meant to "change" the WP admin permanently.

Regards, Jory

Thanks for the feedback Jory!