I’m trying to deactivate the (TeraWallet) plugin for all user roles only allow the subscriber roles.
I’m using this code to deactivate the plugin for the customer role:
function desactivate_plugin_wallet()
{
global $current_user;
if (in_array('customer', $current_user->roles)) {
deactivate_plugins('/woo-wallet/woo-wallet.php');
} else {
activate_plugins('/woo-wallet/woo-wallet.php');
}
}
add_action('admin_init', 'desactivate_plugin_wallet');
And I applying the code to activate the theme dfunction.php file.
But the code not working.
Advance thank you to a great and senior developer to resolve the problem.
2
Answers
As I am testing from my end, It’s working perfectly, My test code sample is:
Basically this happens:
For the customer user group the my_filter_the_plugins disables(silently) the plugin. We then need to reactivate the plugin(silently, again) for those that aren’t in the customer user group.