我必须为某些用户角色禁用折扣插件,我已经编写了此插件并将其放入子主题functions.php
global $woocommerce;
get_currentuserinfo();
global $current_user;
if ($current_user->ID) {
$user_roles = $current_user->roles;
$user_role = array_shift($user_roles);
if ($user_role == \'B2B\') {
deactivate_plugins(\'/httpdocs/wp-content/plugins/woocommerce-payment-discounts/woocommerce-payment-discounts.php\', false);
}
}
但这行不通,为什么?是否正确?停用仅针对用户会话?