disable spesific plugin if log-in with 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 google for hours i 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. becuase 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 spesific plugin if log-in with administrator role

Leave a Reply

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