Hello @03131189-1,
Krzysztof here, form LiveChat’s Technical Department. At the moment, we do not have the possibility to disable the plugin for users with specific role but there’s a workaround that we can offer.
We have prepared a small chunk of code that will allow you to disable the plugin for specified role. All that you have to do is to create a new .php
file, like disable-plugins.php
. After creating such file, add to it the following code:
<?php
/*
Plugin Name: Disable Plugins
*/
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 (ABSPATH . WPINC . '/pluggable.php');
// Get user's role
$user = wp_get_current_user();
// If we user's role is admin
if ( in_array( 'administrator', (array) $user->roles ) ) {
// Use the plugin folder and main file name here.
// is used here as an example
$plugins_not_needed = array ('wp-live-chat-software-for-wordpress/livechat.php');
foreach ( $plugins_not_needed as $plugin ) {
$key = array_search( $plugin, $plugins );
if ( false !== $key ) {
unset( $plugins[ $key ] );
}
}
}
return $plugins;
}
After adding a code, just save changes made to your new disable-plugins.php
file and add it to the following directory in your WordPress root:
/wp-content/mu-plugins/
.
That should disable the LiveChat plugin for users with the administrator role. Also, you can modify the role based on your specific use case, by modifying the following line of code:
if ( in_array( 'administrator', (array) $user->roles ) )
@03131189-1, I hope that we were able to help! In case of any additional questions or concerns, don’t hesitate to ask!
Best regards,
Krzysztof from LiveChat