Restrict role to use a plugin

Your current code disables plugins for logged in users with contributor capabilities on non-admin pages. The is_admin() function checks if the current page is “/wp-admin” page, to disable plugins just on the admin pages change this condition to:

if ( current_user_can( 'contributor' ) && is_admin() ) {

But to make this code work you need to have it in Must-Use plugin, to load it earlier than all the plugins. In short, create new PHP file directly inside /wp-content/mu-plugins directory, add required header information and add your code with the change I mentioned above.


Alternatively, you can use a plugin like Adminimize and disable certain parts of the dashboard to specified users group.

tech