您可以使用以下内容:
add_filter(\'woocommerce_available_payment_gateways\', \'filter_gateways\', 1);
function filter_gateways($gateways)
{
$current_user = wp_get_current_user();
$role = $current_user->roles;
global $woocommerce;
/* add your user role in condition and payment method which you need to unset*/
if ($role[0] == \'administrator\') {
unset($gateways[\'cod\']);
}
return $gateways;
}