Created
April 30, 2018 09:42
-
-
Save kartick14/041c632962da2e6634fdb14f8c46339f to your computer and use it in GitHub Desktop.
Enable/Disable Payment Gateway for a Specific User Role
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @snippet Enable Payment Gateway for a Specific User Role | WooCommerce | |
*/ | |
function custom_paypal_enable_manager( $available_gateways ) { | |
global $woocommerce; | |
if ( isset( $available_gateways['paypal'] ) && !current_user_can('shop_manager') ) { | |
unset( $available_gateways['paypal'] ); | |
} | |
return $available_gateways; | |
} | |
add_filter( 'woocommerce_available_payment_gateways', 'custom_paypal_enable_manager' ); | |
/** | |
* @snippet Disable Payment Gateway for a Specific User Role | WooCommerce | |
*/ | |
function custom_paypal_disable_manager( $available_gateways ) { | |
global $woocommerce; | |
if ( isset( $available_gateways['paypal'] ) && current_user_can('shop_manager') ) { | |
unset( $available_gateways['paypal'] ); | |
} | |
return $available_gateways; | |
} | |
add_filter( 'woocommerce_available_payment_gateways', 'custom_paypal_disable_manager' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment