disable specific plugin if logged in with an administrator role

I found this trick to allow me to do what I want.
This is the code :

add_filter( ‘option_active_plugins’, ‘disable_logged_in_plugin’ );
function disable_logged_in_plugin( $plugins ) {
// The ‘option_active_plugins’ hook occurs before any user information get generated,
// so we need to require this file early to be able to check for logged in status
require_once (ABSPATH . WPINC . ‘/pluggable.php’);
// If we are logged in, and NOT an admin…
if ( current_user_can(‘editor’) || current_user_can(‘administrator’) ) {
// Use the plugin folder and main file name here.
// Bloom is used here as an example
$key = array_search( ‘copyrightpro/copyrightpro.php’ , $plugins );
if ( false !== $key ) {
// Remove the plugin reference, based on its key
unset( $plugins[ $key ] );
// You can “deactive” other plugins here as well,
// using the code above as a template.
return $plugins;

This code work perfectly loaded on folder mu-plugins. The problem is I got this error on wp-admin:

Postman: wp_mail has been declared by another plugin or theme, so you won’t be able to use Postman until the conflict is resolved.
More info that may help – /home/admin/web/yoyoksuharto.com/public_html/wp-includes/pluggable.php:173

After googling for hours I have found it because pluggable.php is already used by other plugin. I just cannot disable that other plugin that use plugable.php, because I also need that plugin.

my question is how do I get around this. Because I need to declare current_user_can(‘editor’) || current_user_can(‘administrator’) inside filter ‘option_active_plugins’ but i cannot use pluggable.

please help me

Read more here:: disable specific plugin if logged in with an administrator role

Leave a Reply

Your email address will not be published. Required fields are marked *