The gform_mollie_payment_methods filter allows you to modify the available payment methods in the Gravity Forms Mollie add-on.
Usage
To use this filter, add the following code to your functions.php
file:
add_filter('gform_mollie_payment_methods', 'your_function_name', 10, 1); function your_function_name($methods) { // your custom code here return $methods; }
Parameters
$methods
(array): The available payment methods.
More information
See Gravity Forms Docs: gform_mollie_payment_methods
Examples
Restrict to specific payment methods
Remove all payment methods except credit card and PayPal:
add_filter('gform_mollie_payment_methods', 'restrict_payment_methods', 10, 1); function restrict_payment_methods($methods) { $allowed_methods = array('creditcard', 'paypal'); $methods = array_intersect_key($methods, array_flip($allowed_methods)); return $methods; }
Sort payment methods by custom order
Sort the payment methods by a predefined custom order:
add_filter('gform_mollie_payment_methods', 'sort_payment_methods', 10, 1); function sort_payment_methods($methods) { $custom_order = array('creditcard', 'paypal', 'ideal'); uksort($methods, function($a, $b) use ($custom_order) { return array_search($a, $custom_order) - array_search($b, $custom_order); }); return $methods; }
Add a custom payment method
Add a custom payment method to the list:
add_filter('gform_mollie_payment_methods', 'add_custom_payment_method', 10, 1); function add_custom_payment_method($methods) { $methods['custom_method'] = 'Custom Payment Method'; return $methods; }
Remove a specific payment method
Remove the ‘ideal’ payment method from the list:
add_filter('gform_mollie_payment_methods', 'remove_ideal_payment_method', 10, 1); function remove_ideal_payment_method($methods) { unset($methods['ideal']); return $methods; }
Rename a payment method
Rename the ‘creditcard’ payment method to ‘Credit Card Payments’:
add_filter('gform_mollie_payment_methods', 'rename_creditcard_payment_method', 10, 1); function rename_creditcard_payment_method($methods) { $methods['creditcard'] = 'Credit Card Payments'; return $methods; }