• Resolved Mo

    (@nadhonar)


    Hi there, Is it possible to hide a Woocommerce gateway based on the USER ROLE? For example if the user has “customer” role, then our gateway won’t be displayed.

    Regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Mo

    (@nadhonar)

    I think we can do this by the following code:

    // Disable Woocommerce payment methods for users with the ‘administrator’ role
    add_filter( ‘woocommerce_available_payment_gateways’, ‘wpsh_disable_gateways_for_admin’, 10, 1 );

    function wpsh_disable_gateways_for_admin( $gateways ) {

    // Check if the current user has the ‘administrator’ role
    if ( current_user_can( ‘administrator’ ) ) {
    // Disable the payment gateway for administrators
    if ( isset( $gateways[‘bacs’] ) ) {
    unset( $gateways[‘bacs’] );
    }
    }

    return $gateways;
    }

    Regards

    Hi @nadhonar,

    Thanks for reaching out.

    I have escalated this with our development team. They will get back to you as soon as possible.

    Kind regards.

    Plugin Author Algoritmika

    (@algoritmika)

    Hi, @nadhonar,

    Thank you for the idea.

    Please update the plugin to the latest v2.3.0 (released today).

    After the update, you will find a new “User Role” section (in “WooCommerce > Settings > Conditional Payment Gateways”).

    Please give it a try and let me know what you think.

    Thread Starter Mo

    (@nadhonar)

    Thanks a lot

    Plugin Author Algoritmika

    (@algoritmika)

    Hi, @nadhonar,

    Happy to help ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.