Last active
July 3, 2024 20:06
-
-
Save jonwaldstein/50f841c98a20dc00a84cecd738e920eb to your computer and use it in GitHub Desktop.
GiveWP filter gateway visibility
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
<?php | |
function filter_give_enabled_payment_gateways($gateways, $formId){ | |
if (!current_user_can('manage_options')) { | |
return array_filter($gateways, function($gateway){ | |
return $gateway !== 'gatewayId'; | |
}, ARRAY_FILTER_USE_KEY); | |
} | |
return $gateways; | |
} | |
// v2 forms | |
add_filter('give_enabled_payment_gateways', 'filter_give_enabled_payment_gateways', 10, 2); | |
// v3 forms | |
add_filter('givewp_donation_form_enabled_gateways', 'filter_give_enabled_payment_gateways', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment