add_filter( 'woocommerce_available_payment_gateways', 'hide_payment_gateway' );
 
function hide_payment_gateway( $available_gateways ) {
global $woocommerce;


if ( isset( $available_gateways['cod'] ) && !current_user_can('administrator') && !current_user_can('staff') && !current_user_can('editor')   ) {
unset( $available_gateways['cod'] );
} 


return $available_gateways;
}