Skip to content

Instantly share code, notes, and snippets.

@jonwaldstein
Last active July 3, 2024 20:06
Show Gist options
  • Save jonwaldstein/50f841c98a20dc00a84cecd738e920eb to your computer and use it in GitHub Desktop.
Save jonwaldstein/50f841c98a20dc00a84cecd738e920eb to your computer and use it in GitHub Desktop.
GiveWP filter gateway visibility
<?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