How can i hide payment options for specific user groups?

WooCommerce, thanks to WordPress, offers the possibility to create different user groups. The default user as a Wocommerce customer is Customer. Now, for example, another user group can be created with the same rights, which are then e.g. resellers. If this particular user group should have an additional payment option that “normal” customers cannot see, this can be solved as follows.

Solution: The following script is inserted in the function.php of the theme at the end.

function customer_disable_manager( $available_gateways ) 
{global $woocommerce;
if ( isset( $available_gateways['hierdiezahlungsart'] ) && current_user_can('customer') ) {
   unset( $available_gateways['hierdiezahlungsart'] );
return $available_gateways;
add_filter( 'woocommerce_available_payment_gateways','customer_disable_manager' );
Without cookies
This website does not use cookies or tracking. More information can be found in the privacy policy.