Last active
April 21, 2026 15:57
-
-
Save andrewlimaza/5ac1ad41189d799e0ba4baab9a0d9e23 to your computer and use it in GitHub Desktop.
Allow query parameter &gateway=xxxx for multiple gateway options at checkout PMPro.
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 | |
| /** | |
| * Allows you to hotswap gateway logic at checkout via query parameter. | |
| * Helpful if the gateway doesn't have native gateway swapping capabilities. | |
| * Add &gateway=paypal (for example) to your checkout URL to load the new PayPal payment gateway. | |
| * | |
| * Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
| */ | |
| add_filter( 'pmpro_valid_gateways', function( $gateways ) { | |
| $gateways[] = 'paypal'; //Change paypal to any other gateway you have installed/configured. | |
| return $gateways; | |
| } ); | |
| // Add a small "Click here to checkout with PayPal" example link to reload the checkout and use PayPal. | |
| add_action( 'pmpro_checkout_after_level_cost', function( $level ) { | |
| if ( ! isset( $_REQUEST['gateway'] ) ) { | |
| echo '<p><a href="' . esc_url( add_query_arg( 'gateway', 'paypal' ) ) . '">Click here to checkout with PayPal</a></p>'; | |
| } | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment